[Summary]

Improve logic of replacing session.
Improve delete unnecessary files and directories on replace session.

[Reviewed] GZharun

[git-p4: depot-paths = "//Abdaw/dev_main/tracks/": change = 465616]
This commit is contained in:
Nikolay Polyanovskii 2014-06-05 04:54:47 -05:00 committed by Paul Davis
parent 0ea0fe893d
commit 2ee481e8df
5 changed files with 189 additions and 145 deletions

View file

@ -43,6 +43,10 @@ namespace ARDOUR {
LIBARDOUR_API extern const char* const user_config_dir_name;
LIBARDOUR_API extern const char* const panner_dir_name;
LIBARDOUR_API extern const char* const backend_dir_name;
LIBARDOUR_API extern const char* const automation_dir_name;
LIBARDOUR_API extern const char* const analysis_dir_name;
LIBARDOUR_API extern const char* const plugins_dir_name;
LIBARDOUR_API extern const char* const externals_dir_name;
};

View file

@ -39,6 +39,10 @@ const char* const surfaces_dir_name = X_("surfaces");
const char* const ladspa_dir_name = X_("ladspa");
const char* const panner_dir_name = X_("panners");
const char* const backend_dir_name = X_("backends");
const char* const automation_dir_name = X_("automation");
const char* const analysis_dir_name = X_("analysis");
const char* const plugins_dir_name = X_("plugins");
const char* const externals_dir_name = X_("externals");
char config_dir_name[] = X_(PROGRAM_NAME "3");
#if defined (__APPLE__) || defined (PLATFORM_WINDOWS)

View file

@ -127,19 +127,6 @@ using namespace std;
using namespace ARDOUR;
using namespace PBD;
namespace
{
string
get_session_projectfile_name(string session_path)
{
string s0 = session_path;
string s1 = Glib::path_get_dirname (s0);
s0.erase(0, s1.size());
return session_path + s0 + ".ardour";
}
}
void
Session::pre_engine_init (string fullpath)
{
@ -160,7 +147,10 @@ Session::pre_engine_init (string fullpath)
/* is it new ? */
_is_new = !Glib::file_test ( get_session_projectfile_name(fullpath), Glib::FileTest (G_FILE_TEST_EXISTS));
string full_session_name = Glib::build_filename( fullpath, _name );
full_session_name += statefile_suffix;
_is_new = !Glib::file_test ( full_session_name, Glib::FileTest (G_FILE_TEST_EXISTS));
/* finish initialization that can't be done in a normal C++ constructor
definition.
@ -421,15 +411,17 @@ Session::ensure_subdirs ()
dir = session_directory().peak_path();
if (g_mkdir_with_parents (dir.c_str(), 0755) < 0) {
error << string_compose(_("Session: cannot create session peakfile folder \"%1\" (%2)"), dir, strerror (errno)) << endmsg;
return -1;
}
// if directory allready exists do not create it again
if ( !Glib::file_test (dir.c_str(), Glib::FileTest (G_FILE_TEST_EXISTS))) {
if (g_mkdir_with_parents (dir.c_str(), 0755) < 0) {
error << string_compose(_("Session: cannot create session peakfile folder \"%1\" (%2)"), dir, strerror (errno)) << endmsg;
return -1;
}
}
dir = session_directory().sound_path();
// if directory 'interchange' allready exists do not create it again
if ( !Glib::file_test (dir.c_str(), Glib::FileTest (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) {
if ( !Glib::file_test (dir.c_str(), Glib::FileTest (G_FILE_TEST_EXISTS))) {
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;
@ -438,45 +430,57 @@ Session::ensure_subdirs ()
dir = session_directory().midi_path();
if (g_mkdir_with_parents (dir.c_str(), 0755) < 0) {
error << string_compose(_("Session: cannot create session midi dir \"%1\" (%2)"), dir, strerror (errno)) << endmsg;
return -1;
if ( !Glib::file_test (dir.c_str(), Glib::FileTest (G_FILE_TEST_EXISTS))) {
if (g_mkdir_with_parents (dir.c_str(), 0755) < 0) {
error << string_compose(_("Session: cannot create session midi dir \"%1\" (%2)"), dir, strerror (errno)) << endmsg;
return -1;
}
}
dir = session_directory().dead_path();
if (g_mkdir_with_parents (dir.c_str(), 0755) < 0) {
error << string_compose(_("Session: cannot create session dead sounds folder \"%1\" (%2)"), dir, strerror (errno)) << endmsg;
return -1;
}
if ( !Glib::file_test (dir.c_str(), Glib::FileTest (G_FILE_TEST_EXISTS))) {
if (g_mkdir_with_parents (dir.c_str(), 0755) < 0) {
error << string_compose(_("Session: cannot create session dead sounds folder \"%1\" (%2)"), dir, strerror (errno)) << endmsg;
return -1;
}
}
dir = session_directory().export_path();
if (g_mkdir_with_parents (dir.c_str(), 0755) < 0) {
error << string_compose(_("Session: cannot create session export folder \"%1\" (%2)"), dir, strerror (errno)) << endmsg;
return -1;
}
if ( !Glib::file_test (dir.c_str(), Glib::FileTest (G_FILE_TEST_EXISTS))) {
if (g_mkdir_with_parents (dir.c_str(), 0755) < 0) {
error << string_compose(_("Session: cannot create session export folder \"%1\" (%2)"), dir, strerror (errno)) << endmsg;
return -1;
}
}
dir = analysis_dir ();
if (g_mkdir_with_parents (dir.c_str(), 0755) < 0) {
error << string_compose(_("Session: cannot create session analysis folder \"%1\" (%2)"), dir, strerror (errno)) << endmsg;
return -1;
}
if ( !Glib::file_test (dir.c_str(), Glib::FileTest (G_FILE_TEST_EXISTS))) {
if (g_mkdir_with_parents (dir.c_str(), 0755) < 0) {
error << string_compose(_("Session: cannot create session analysis folder \"%1\" (%2)"), dir, strerror (errno)) << endmsg;
return -1;
}
}
dir = plugins_dir ();
if (g_mkdir_with_parents (dir.c_str(), 0755) < 0) {
error << string_compose(_("Session: cannot create session plugins folder \"%1\" (%2)"), dir, strerror (errno)) << endmsg;
return -1;
}
if ( !Glib::file_test (dir.c_str(), Glib::FileTest (G_FILE_TEST_EXISTS))) {
if (g_mkdir_with_parents (dir.c_str(), 0755) < 0) {
error << string_compose(_("Session: cannot create session plugins folder \"%1\" (%2)"), dir, strerror (errno)) << endmsg;
return -1;
}
}
dir = externals_dir ();
if (g_mkdir_with_parents (dir.c_str(), 0755) < 0) {
error << string_compose(_("Session: cannot create session externals folder \"%1\" (%2)"), dir, strerror (errno)) << endmsg;
return -1;
}
if ( !Glib::file_test (dir.c_str(), Glib::FileTest (G_FILE_TEST_EXISTS))) {
if (g_mkdir_with_parents (dir.c_str(), 0755) < 0) {
error << string_compose(_("Session: cannot create session externals folder \"%1\" (%2)"), dir, strerror (errno)) << endmsg;
return -1;
}
}
return 0;
}
@ -2207,25 +2211,25 @@ Session::get_best_session_directory_for_new_source ()
string
Session::automation_dir () const
{
return Glib::build_filename (_path, "automation");
return Glib::build_filename (_path, automation_dir_name);
}
string
Session::analysis_dir () const
{
return Glib::build_filename (_path, "analysis");
return Glib::build_filename (_path, analysis_dir_name);
}
string
Session::plugins_dir () const
{
return Glib::build_filename (_path, "plugins");
return Glib::build_filename (_path, plugins_dir_name);
}
string
Session::externals_dir () const
{
return Glib::build_filename (_path, "externals");
return Glib::build_filename (_path, externals_dir_name);
}
int