13
0

copy demo sessions

This commit is contained in:
Robin Gareus 2016-09-13 19:31:38 +02:00
parent f57e2f2fbe
commit 8e995be5cf

View File

@ -56,6 +56,7 @@
#include "pbd/compose.h"
#include "pbd/convert.h"
#include "pbd/failed_constructor.h"
#include "pbd/file_archive.h"
#include "pbd/enumwriter.h"
#include "pbd/memento_command.h"
#include "pbd/openuri.h"
@ -1069,6 +1070,45 @@ ARDOUR_UI::starting ()
}
}
// TODO: maybe IFF brand_new_user
if (ARDOUR::Profile->get_mixbus () && Config->get_copy_demo_sessions ()) {
std::string dspd (Config->get_default_session_parent_dir());
Searchpath ds (ARDOUR::ardour_data_search_path());
ds.add_subdirectory_to_paths ("sessions");
vector<string> demos;
find_files_matching_pattern (demos, ds, "*.tar.xz");
ARDOUR::RecentSessions rs;
ARDOUR::read_recent_sessions (rs);
for (vector<string>::iterator i = demos.begin(); i != demos.end (); ++i) {
/* "demo-session" must be inside "demo-session.tar.xz"
* strip ".tar.xz"
*/
std::string name = basename_nosuffix (basename_nosuffix (*i));
std::string path = Glib::build_filename (dspd, name);
/* skip if session-dir already exists */
if (Glib::file_test(path.c_str(), Glib::FILE_TEST_IS_DIR)) {
continue;
}
/* skip sessions that are already in 'recent'.
* eg. a new user changed <session-default-dir> shorly after installation
*/
for (ARDOUR::RecentSessions::iterator r = rs.begin(); r != rs.end(); ++r) {
if ((*r).first == name) {
continue;
}
}
try {
PBD::FileArchive ar (*i);
if (0 == ar.inflate (dspd)) {
store_recent_sessions (name, path);
info << string_compose (_("Copied Demo Session %1."), name) << endmsg;
}
} catch (...) {}
}
}
#ifdef NO_PLUGIN_STATE
ARDOUR::RecentSessions rs;