mirror of
https://github.com/Ardour/ardour.git
synced 2026-01-01 03:17:39 +01:00
[Summary] Igor's letter, point 4. Replace/Create new session with same name - when user tries to create new session with same name as existing session.
[Reviewed] GZharun [git-p4: depot-paths = "//Abdaw/dev_main/tracks/": change = 464235]
This commit is contained in:
parent
8668d6e245
commit
a5d4b64ee0
2 changed files with 127 additions and 17 deletions
|
|
@ -82,6 +82,7 @@
|
|||
#include "ardour/session_utils.h"
|
||||
#include "ardour/slave.h"
|
||||
#include "ardour/system_exec.h"
|
||||
#include "ardour/directory_names.h"
|
||||
#include "dbg_msg.h"
|
||||
|
||||
#ifdef WINDOWS_VST_SUPPORT
|
||||
|
|
@ -2830,14 +2831,107 @@ ARDOUR_UI::get_session_parameters (bool quit_on_cancel, bool should_be_new, stri
|
|||
if (likely_new && !nsm) {
|
||||
|
||||
std::string existing = Glib::build_filename (session_path, session_name);
|
||||
|
||||
bool do_not_create_session = false;
|
||||
|
||||
if (!ask_about_loading_existing_session (existing)) {
|
||||
ARDOUR_COMMAND_LINE::session_name = ""; // cancel that
|
||||
continue;
|
||||
}
|
||||
}
|
||||
GDir *dir;
|
||||
GError *error;
|
||||
const gchar *file_name;
|
||||
|
||||
dir = g_dir_open(session_path.c_str(), 0, &error);
|
||||
|
||||
while ((file_name = g_dir_read_name(dir)))
|
||||
{
|
||||
string ff = string(file_name);
|
||||
|
||||
string full_file_name = g_build_filename(session_path.c_str(), file_name);
|
||||
|
||||
string str_file_name = string(file_name);
|
||||
string interchange_debug = string(ARDOUR::interchange_dir_name);
|
||||
|
||||
if( (g_file_test (full_file_name.c_str(), GFileTest (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) &&
|
||||
(str_file_name == interchange_debug) )
|
||||
{
|
||||
cout<<endl<<full_file_name<<" WAS NOT deleted \n\n"<<flush;
|
||||
continue;
|
||||
}
|
||||
|
||||
_session_is_new = false;
|
||||
if( g_file_test (full_file_name.c_str(), GFileTest (G_FILE_TEST_EXISTS)) &&
|
||||
string(file_name) != string(ARDOUR::interchange_dir_name) )
|
||||
{
|
||||
|
||||
try {
|
||||
if( g_remove(full_file_name.c_str() ) >=0 )
|
||||
cout<<full_file_name<<" file was deleted \n"<<flush;
|
||||
else
|
||||
{
|
||||
cout<<full_file_name<<" file was not deleted (ELSE) \n"<<flush;
|
||||
|
||||
string message = "Can not replace session. File: file " + full_file_name + " can not be deleted";
|
||||
MessageDialog msg (message.c_str(),
|
||||
false,
|
||||
Gtk::MESSAGE_WARNING,
|
||||
Gtk::BUTTONS_OK,
|
||||
true);
|
||||
|
||||
msg.set_position (Gtk::WIN_POS_MOUSE);
|
||||
msg.run();
|
||||
|
||||
do_not_create_session = true;
|
||||
break;
|
||||
}
|
||||
|
||||
} catch (...) {
|
||||
cout<<full_file_name<<" file was not deleted (CATCH) \n"<<flush;
|
||||
|
||||
string message = "Can not replace session. File: file " + full_file_name + " can not be deleted";
|
||||
MessageDialog msg (message.c_str(),
|
||||
false,
|
||||
Gtk::MESSAGE_WARNING,
|
||||
Gtk::BUTTONS_OK,
|
||||
true);
|
||||
|
||||
msg.set_position (Gtk::WIN_POS_MOUSE);
|
||||
msg.run();
|
||||
|
||||
do_not_create_session = true;
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
// file is a directory
|
||||
if( (Glib::file_test (full_file_name, Glib::FileTest (G_FILE_TEST_IS_DIR))) )
|
||||
{
|
||||
try {
|
||||
if( g_rmdir(full_file_name.c_str())>=0 )
|
||||
cout<<full_file_name<<" directory was deleted \n"<<flush;
|
||||
else
|
||||
cout<<full_file_name<<" directory was not deleted \n"<<flush;
|
||||
} catch (...) {
|
||||
cerr<<"ERROR :: Can not delete directroy: "<<file_name<<endl<<flush;
|
||||
}
|
||||
} else {
|
||||
// file is not a directory
|
||||
try {
|
||||
if(unlink(full_file_name.c_str())>=0)
|
||||
cout<<full_file_name<<" file was deleted"<<endl<<flush;
|
||||
else
|
||||
cout<<full_file_name<<" file was not deleted"<<endl<<flush;
|
||||
} catch (...) {
|
||||
cerr<<"ERROR :: Can not delete file: "<<file_name<<endl<<flush;
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
if( do_not_create_session )
|
||||
continue;
|
||||
|
||||
_session_is_new = true;
|
||||
} else
|
||||
_session_is_new = false;
|
||||
|
||||
} else {
|
||||
|
||||
|
|
|
|||
|
|
@ -127,6 +127,19 @@ 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)
|
||||
{
|
||||
|
|
@ -144,10 +157,10 @@ Session::pre_engine_init (string fullpath)
|
|||
if (_path[_path.length()-1] != G_DIR_SEPARATOR) {
|
||||
_path += G_DIR_SEPARATOR;
|
||||
}
|
||||
|
||||
|
||||
/* is it new ? */
|
||||
|
||||
_is_new = !Glib::file_test (_path, Glib::FileTest (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR));
|
||||
_is_new = !Glib::file_test ( get_session_projectfile_name(fullpath), Glib::FileTest (G_FILE_TEST_EXISTS));
|
||||
|
||||
/* finish initialization that can't be done in a normal C++ constructor
|
||||
definition.
|
||||
|
|
@ -415,17 +428,20 @@ Session::ensure_subdirs ()
|
|||
|
||||
dir = session_directory().sound_path();
|
||||
|
||||
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 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 (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 = 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 (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();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue