summaryrefslogtreecommitdiff
path: root/libs/pbd/filesystem.cc
diff options
context:
space:
mode:
authorTim Mayberry <mojofunk@gmail.com>2007-05-19 11:31:27 +0000
committerTim Mayberry <mojofunk@gmail.com>2007-05-19 11:31:27 +0000
commitb99c6c6e1d5a2f8f653f64e1ee3788f77a11a120 (patch)
treec1558d417203acc553cdb48a0b8f45e0e3f7d1ea /libs/pbd/filesystem.cc
parentfd6408e6baf9094d73a4b6c1b5b24455b11124b2 (diff)
When loading sessions, create any missing session directories rather than throwing an exception.
Change the meaning of the return value of SessionDirectory::create and add documentation to explain usage. Add PBD::sys::filesystem_error to indicate a filesystem error and throw it where necessary. Change the semantics of PBD::sys::create_directory/ies functions to match boost::filesystem git-svn-id: svn://localhost/ardour2/trunk@1884 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/pbd/filesystem.cc')
-rw-r--r--libs/pbd/filesystem.cc22
1 files changed, 14 insertions, 8 deletions
diff --git a/libs/pbd/filesystem.cc b/libs/pbd/filesystem.cc
index f376fa72f0..229b22fcb5 100644
--- a/libs/pbd/filesystem.cc
+++ b/libs/pbd/filesystem.cc
@@ -21,6 +21,8 @@
#include <glib.h>
#include <glib/gstdio.h>
+#include <cerrno>
+
#include <glibmm/fileutils.h>
#include <glibmm/miscutils.h>
@@ -67,24 +69,28 @@ is_directory (const path & p)
bool
create_directory(const path & p)
{
- if (g_mkdir (p.to_string().c_str(), S_IRWXU|S_IRWXG|S_IRWXO) != 0)
+ if(is_directory(p)) return false;
+
+ int error = g_mkdir (p.to_string().c_str(), S_IRWXU|S_IRWXG|S_IRWXO);
+
+ if(error == -1)
{
- warning << "Unable to create directory at path: " << p.to_string() << endmsg;
- return false;
+ throw filesystem_error(g_strerror(errno), errno);
}
-
return true;
}
bool
create_directories(const path & p)
{
- if (g_mkdir_with_parents (p.to_string().c_str(), S_IRWXU|S_IRWXG|S_IRWXO) != 0)
+ if(is_directory(p)) return false;
+
+ int error = g_mkdir_with_parents (p.to_string().c_str(), S_IRWXU|S_IRWXG|S_IRWXO);
+
+ if(error == -1)
{
- warning << "Unable to create directory at path: " << p.to_string() << endmsg;
- return false;
+ throw filesystem_error(g_strerror(errno), errno);
}
-
return true;
}