diff options
author | David Robillard <d@drobilla.net> | 2008-01-10 21:20:59 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2008-01-10 21:20:59 +0000 |
commit | bb457bb960c5bd7ed538f9d31477293415739f68 (patch) | |
tree | 84324a63b87c03589cd165b9e474296eaebb4772 /libs/ardour/session_state.cc | |
parent | 73dd9d37e7d715e0d78c0e51569968f9494dac7f (diff) |
Merge libs/ardour and gtk2_ardour with 2.0-ongoing R2837.
git-svn-id: svn://localhost/ardour2/trunk@2883 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/session_state.cc')
-rw-r--r-- | libs/ardour/session_state.cc | 121 |
1 files changed, 89 insertions, 32 deletions
diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index 877047d93a..fa4b103958 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -418,49 +418,106 @@ Session::setup_raid_path (string path) last_rr_session_dir = session_dirs.begin(); } -void -Session::initialize_start_and_end_locations (nframes_t start, nframes_t end) +int +Session::create (bool& new_session, const string& mix_template, nframes_t initial_length) { - start_location->set_end (start); - _locations.add (start_location); + string dir; - end_location->set_end (end); - _locations.add (end_location); -} + if (g_mkdir_with_parents (_path.c_str(), 0755) < 0) { + error << string_compose(_("Session: cannot create session dir \"%1\" (%2)"), _path, strerror (errno)) << endmsg; + return -1; + } -bool -Session::create_session_file () -{ - _state_of_the_state = Clean; + dir = session_directory().peak_path().to_string(); - if (save_state (_current_snapshot_name)) { - error << "Could not create new session file" << endmsg; - return false; + if (g_mkdir_with_parents (dir.c_str(), 0755) < 0) { + error << string_compose(_("Session: cannot create session peakfile dir \"%1\" (%2)"), dir, strerror (errno)) << endmsg; + return -1; } - return true; -} -bool -Session::create_session_file_from_template (const string& template_path) -{ - sys::path session_file_path(_session_dir->root_path()); + dir = session_directory().sound_path().to_string(); - session_file_path /= _name + statefile_suffix; + 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().to_string(); - try - { - sys::copy_file (template_path, session_file_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; } - catch(sys::filesystem_error& ex) - { - error << string_compose (_("Could not use session template %1 to create new session (%2)."), - template_path, ex.what()) - << endmsg; - return false; + + dir = session_directory().dead_sound_path().to_string(); + + if (g_mkdir_with_parents (dir.c_str(), 0755) < 0) { + error << string_compose(_("Session: cannot create session dead sounds dir \"%1\" (%2)"), dir, strerror (errno)) << endmsg; + return -1; } - return true; + + dir = session_directory().export_path().to_string(); + + if (g_mkdir_with_parents (dir.c_str(), 0755) < 0) { + error << string_compose(_("Session: cannot create session export dir \"%1\" (%2)"), dir, strerror (errno)) << endmsg; + return -1; + } + + + /* check new_session so we don't overwrite an existing one */ + + if (!mix_template.empty()) { + std::string in_path = mix_template; + + ifstream in(in_path.c_str()); + + if (in){ + string out_path = _path; + out_path += _name; + out_path += statefile_suffix; + + ofstream out(out_path.c_str()); + + if (out){ + out << in.rdbuf(); + + // okay, session is set up. Treat like normal saved + // session from now on. + + new_session = false; + return 0; + + } else { + error << string_compose (_("Could not open %1 for writing mix template"), out_path) + << endmsg; + return -1; + } + + } else { + error << string_compose (_("Could not open mix template %1 for reading"), in_path) + << endmsg; + return -1; + } + + } + + /* set initial start + end point */ + + start_location->set_end (0); + _locations.add (start_location); + + end_location->set_end (initial_length); + _locations.add (end_location); + + _state_of_the_state = Clean; + + + save_state (""); + + return 0; } + int Session::load_diskstreams (const XMLNode& node) { @@ -2767,7 +2824,7 @@ Session::restore_history (string snapshot_name) const string xml_filename = snapshot_name + history_suffix; const sys::path xml_path = _session_dir->root_path() / xml_filename; - info << string_compose(_("Loading history from '%1'."), xml_path.to_string()) << endmsg; + cerr << "Loading history from " << xml_path.to_string() << endmsg; if (!sys::exists (xml_path)) { info << string_compose (_("%1: no history file \"%2\" for this session."), |