prevent inadvertent "sounds" dir from 0.99 from confusing 2.0

git-svn-id: svn://localhost/ardour2/trunk@1509 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2007-02-25 21:54:59 +00:00
parent eae83763fb
commit 1e352b699e
2 changed files with 58 additions and 22 deletions

View file

@ -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 ();

View file

@ -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,16 +1856,56 @@ Session::dead_sound_dir () const
{
string res = _path;
res += dead_sound_dir_name;
res += '/';
return res;
}
string
Session::old_sound_dir (bool with_path) const
{
string res;
if (with_path) {
res = _path;
}
res += old_sound_dir_name;
return res;
}
string
Session::sound_dir (bool with_path) const
{
/* support old session structure */
string res;
string full;
if (with_path) {
res = _path;
} else {
full = _path;
}
res += interchange_dir_name;
res += '/';
res += legalize_for_path (_name);
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 */
struct stat statbuf;
string old_nopath;
string old_withpath;
@ -1869,25 +1914,15 @@ Session::sound_dir (bool with_path) const
old_withpath = _path;
old_withpath += old_sound_dir_name;
if (stat (old_withpath.c_str(), &statbuf) == 0) {
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;
}
string res;
if (with_path) {
res = _path;
}
res += interchange_dir_name;
res += '/';
res += legalize_for_path (_name);
res += '/';
res += sound_dir_name;
/* ok, old "sounds" directory isn't there, return the new path */
return res;
}