diff options
Diffstat (limited to 'libs/pbd/filesystem.cc')
-rw-r--r-- | libs/pbd/filesystem.cc | 22 |
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; } |