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
This commit is contained in:
Tim Mayberry 2007-05-19 11:31:27 +00:00
parent fd6408e6ba
commit b99c6c6e1d
5 changed files with 111 additions and 30 deletions

View file

@ -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)
{
warning << "Unable to create directory at path: " << p.to_string() << endmsg;
return false;
}
if(is_directory(p)) return false;
int error = g_mkdir (p.to_string().c_str(), S_IRWXU|S_IRWXG|S_IRWXO);
if(error == -1)
{
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)
{
warning << "Unable to create directory at path: " << p.to_string() << endmsg;
return false;
}
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)
{
throw filesystem_error(g_strerror(errno), errno);
}
return true;
}