summaryrefslogtreecommitdiff
path: root/cpp/src/qpid/DataDir.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/qpid/DataDir.cpp')
-rw-r--r--cpp/src/qpid/DataDir.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/cpp/src/qpid/DataDir.cpp b/cpp/src/qpid/DataDir.cpp
index 5fa26082b3..e9c6aaad53 100644
--- a/cpp/src/qpid/DataDir.cpp
+++ b/cpp/src/qpid/DataDir.cpp
@@ -41,8 +41,14 @@ DataDir::DataDir (std::string path) :
const char *cpath = dirPath.c_str ();
struct stat s;
- if (::stat (cpath, &s))
- throw Exception ("Data directory not found: " + path);
+ if (::stat(cpath, &s)) {
+ if (errno == ENOENT) {
+ if (::mkdir(cpath, 0755))
+ throw Exception ("Can't create data directory: " + path);
+ }
+ else
+ throw Exception ("Data directory not found: " + path);
+ }
std::string lockFile (path);
lockFile = lockFile + "/lock";
@@ -51,9 +57,9 @@ DataDir::DataDir (std::string path) :
if (fd == -1)
{
if (errno == EEXIST)
- throw Exception ("Data directory is locked by another process");
+ throw Exception ("Data directory is locked by another process: " + path);
if (errno == EACCES)
- throw Exception ("Insufficient privileges for data directory");
+ throw Exception ("Insufficient privileges for data directory: " + path);
throw Exception(
QPID_MSG("Error locking " << lockFile << ": " << strError(errno)));
}