diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2007-02-25 21:54:59 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2007-02-25 21:54:59 +0000 |
commit | 1e352b699edad2b08f79206af1d2e462a19b44ef (patch) | |
tree | ebfe2a8c46b9181c6f8c53fb9b7b204f4cb9229e /libs/ardour | |
parent | eae83763fb607ac0b7381ec06ce2b2e595def7ea (diff) |
prevent inadvertent "sounds" dir from 0.99 from confusing 2.0
git-svn-id: svn://localhost/ardour2/trunk@1509 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour')
-rw-r--r-- | libs/ardour/ardour/session.h | 3 | ||||
-rw-r--r-- | libs/ardour/session_state.cc | 77 |
2 files changed, 58 insertions, 22 deletions
diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index 39bb9c3e68..57c9eca660 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -1567,7 +1567,8 @@ class Session : public PBD::StatefulDestructible static const char* interchange_dir_name; static const char* peak_dir_name; static const char* export_dir_name; - + + string old_sound_dir (bool with_path = true) const; string discover_best_sound_dir (bool destructive = false); int ensure_sound_dir (string, string&); void refresh_disk_space (); diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index ab6e91ba9b..ea35e853ec 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -465,11 +465,16 @@ Session::create (bool& new_session, string* mix_template, nframes_t initial_leng return -1; } - dir = sound_dir (); + /* if this is is an existing session with an old "sounds" directory, just use it. see Session::sound_dir() for more details */ - if (g_mkdir_with_parents (dir.c_str(), 0755) < 0) { - error << string_compose(_("Session: cannot create session sounds dir \"%1\" (%2)"), dir, strerror (errno)) << endmsg; - return -1; + if (!Glib::file_test (old_sound_dir(), Glib::FILE_TEST_EXISTS|Glib::FILE_TEST_IS_DIR)) { + + dir = sound_dir (); + + if (g_mkdir_with_parents (dir.c_str(), 0755) < 0) { + error << string_compose(_("Session: cannot create session sounds dir \"%1\" (%2)"), dir, strerror (errno)) << endmsg; + return -1; + } } dir = dead_sound_dir (); @@ -1851,36 +1856,34 @@ Session::dead_sound_dir () const { string res = _path; res += dead_sound_dir_name; - res += '/'; + return res; } string -Session::sound_dir (bool with_path) const +Session::old_sound_dir (bool with_path) const { - /* support old session structure */ + string res; - struct stat statbuf; - string old_nopath; - string old_withpath; + if (with_path) { + res = _path; + } - old_nopath += old_sound_dir_name; - old_nopath += '/'; - - old_withpath = _path; - old_withpath += old_sound_dir_name; + res += old_sound_dir_name; - if (stat (old_withpath.c_str(), &statbuf) == 0) { - if (with_path) - return old_withpath; - - return old_nopath; - } + return res; +} +string +Session::sound_dir (bool with_path) const +{ string res; + string full; if (with_path) { res = _path; + } else { + full = _path; } res += interchange_dir_name; @@ -1889,6 +1892,38 @@ Session::sound_dir (bool with_path) const res += '/'; res += sound_dir_name; + if (with_path) { + full = res; + } else { + full += res; + } + + /* if this already exists, don't check for the old session sound directory */ + + if (Glib::file_test (full, Glib::FILE_TEST_IS_DIR|Glib::FILE_TEST_EXISTS)) { + return res; + } + + /* possibly support old session structure */ + + string old_nopath; + string old_withpath; + + old_nopath += old_sound_dir_name; + old_nopath += '/'; + + old_withpath = _path; + old_withpath += old_sound_dir_name; + + if (Glib::file_test (old_withpath.c_str(), Glib::FILE_TEST_IS_DIR|Glib::FILE_TEST_EXISTS)) { + if (with_path) + return old_withpath; + + return old_nopath; + } + + /* ok, old "sounds" directory isn't there, return the new path */ + return res; } |