summaryrefslogtreecommitdiff
path: root/libs/ardour/session_directory.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/ardour/session_directory.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/ardour/session_directory.cc')
-rw-r--r--libs/ardour/session_directory.cc24
1 files changed, 15 insertions, 9 deletions
diff --git a/libs/ardour/session_directory.cc b/libs/ardour/session_directory.cc
index e871b84244..91b2587eb7 100644
--- a/libs/ardour/session_directory.cc
+++ b/libs/ardour/session_directory.cc
@@ -43,23 +43,29 @@ SessionDirectory::SessionDirectory (const string& session_path)
bool
SessionDirectory::create ()
{
- if (is_directory (m_root_path))
- {
- PBD::error << string_compose(_("Cannot create Session directory at path %1 as it already exists"), m_root_path.to_string()) << endmsg;
- return false;
- }
+ bool is_new = false;
vector<path> sub_dirs = sub_directories ();
for (vector<path>::const_iterator i = sub_dirs.begin(); i != sub_dirs.end(); ++i)
{
- if (!create_directories(*i))
+ try
{
- PBD::error << string_compose(_("Cannot create Session directory at path %1 Error: %2"), (*i).to_string(), g_strerror (errno)) << endmsg;
- return false;
+ if(create_directories(*i)) {
+ PBD::info << string_compose(_("Created Session directory at path %1"), (*i).to_string()) << endmsg;
+ is_new = true;
+ }
+ }
+ catch (PBD::sys::filesystem_error& ex)
+ {
+ // log the error
+ PBD::error << string_compose(_("Cannot create Session directory at path %1 Error: %2"), (*i).to_string(), ex.what()) << endmsg;
+
+ // and rethrow
+ throw ex;
}
}
- return true;
+ return is_new;
}
bool