summaryrefslogtreecommitdiff
path: root/cpp/src/qpid/DataDir.cpp
diff options
context:
space:
mode:
authorStephen D. Huston <shuston@apache.org>2008-10-07 15:19:50 +0000
committerStephen D. Huston <shuston@apache.org>2008-10-07 15:19:50 +0000
commit4eb2dca5b9ae07228f542cd798b44cc44ea96c09 (patch)
tree9d1de3abe8bca9ff0617432056217bfab12b00f5 /cpp/src/qpid/DataDir.cpp
parentcdae2a877123056b69a91dd8ca2196577654de2d (diff)
downloadqpid-python-4eb2dca5b9ae07228f542cd798b44cc44ea96c09.tar.gz
Abstract native file-locking and directory detection/creation to portable classes LockFile and FileSysDir; resolves QPID-1148
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@702513 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/DataDir.cpp')
-rw-r--r--cpp/src/qpid/DataDir.cpp20
1 files changed, 4 insertions, 16 deletions
diff --git a/cpp/src/qpid/DataDir.cpp b/cpp/src/qpid/DataDir.cpp
index 18b52b9b8f..4d61d22219 100644
--- a/cpp/src/qpid/DataDir.cpp
+++ b/cpp/src/qpid/DataDir.cpp
@@ -21,12 +21,7 @@
#include "Exception.h"
#include "DataDir.h"
#include "qpid/log/Statement.h"
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/file.h>
-#include <fcntl.h>
-#include <cerrno>
-#include <unistd.h>
+#include "qpid/sys/FileSysDir.h"
namespace qpid {
@@ -40,16 +35,9 @@ DataDir::DataDir (std::string path) :
return;
}
- const char *cpath = dirPath.c_str ();
- struct stat s;
- 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);
- }
+ sys::FileSysDir dir(dirPath);
+ if (!dir.exists())
+ dir.mkdir();
std::string lockFileName(path);
lockFileName += "/lock";
lockFile = std::auto_ptr<sys::LockFile>(new sys::LockFile(lockFileName, true));