aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--src/messaging/maildirStore.cpp22
2 files changed, 25 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 8d29a7c1..6220fbe3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,11 @@
VERSION 0.6.1-cvs
=================
+2004-12-23 Vincent Richard <[email protected]>
+
+ * maildir: when connecting to the store, create root directory on the
+ file system if it does not exist.
+
2004-12-22 Vincent Richard <[email protected]>
* Fixed missing files in distribution (src/platform/*).
diff --git a/src/messaging/maildirStore.cpp b/src/messaging/maildirStore.cpp
index 206c032b..a74e4c7d 100644
--- a/src/messaging/maildirStore.cpp
+++ b/src/messaging/maildirStore.cpp
@@ -102,8 +102,26 @@ void maildirStore::connect()
if (isConnected())
throw exceptions::already_connected();
- m_fsPath = platformDependant::getHandler()->getFileSystemFactory()->
- stringToPath(getSession()->getProperties()[getInfos().getPropertyPrefix() + "server.rootpath"]);
+ // Get root directory
+ utility::fileSystemFactory* fsf = platformDependant::getHandler()->getFileSystemFactory();
+
+ m_fsPath = fsf->stringToPath
+ (getSession()->getProperties()[getInfos().getPropertyPrefix() + "server.rootpath"]);
+
+ utility::auto_ptr <utility::file> rootDir = fsf->create(m_fsPath);
+
+ // Try to create the root directory if it does not exist
+ if (!(rootDir->exists() && rootDir->isDirectory()))
+ {
+ try
+ {
+ rootDir->createDirectory();
+ }
+ catch (exceptions::filesystem_exception& e)
+ {
+ throw exceptions::connection_error(e);
+ }
+ }
m_connected = true;
}