move "been here before" path concept into libardour, and use it appropriately at startup
This commit is contained in:
parent
ea5e94977b
commit
207ac16731
@ -115,13 +115,23 @@ ArdourStartup::~ArdourStartup ()
|
||||
bool
|
||||
ArdourStartup::required ()
|
||||
{
|
||||
return !Glib::file_test (been_here_before_path(), Glib::FILE_TEST_EXISTS);
|
||||
}
|
||||
/* look for a "been here before" file for this version or earlier
|
||||
* versions
|
||||
*/
|
||||
|
||||
std::string
|
||||
ArdourStartup::been_here_before_path ()
|
||||
{
|
||||
return Glib::build_filename (user_config_directory (), ".a" PROGRAM_VERSION);
|
||||
const int current_version = atoi (PROGRAM_VERSION);
|
||||
|
||||
for (int v = current_version; v != 0; --v) {
|
||||
if (Glib::file_test (ARDOUR::been_here_before_path (v), Glib::FILE_TEST_EXISTS)) {
|
||||
if (v != current_version) {
|
||||
/* older version exists, create the current one */
|
||||
ofstream fout (been_here_before_path (current_version).c_str());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -60,8 +60,6 @@ class ArdourStartup : public Gtk::Assistant {
|
||||
bool config_modified;
|
||||
bool new_user;
|
||||
|
||||
static std::string been_here_before_path ();
|
||||
|
||||
void on_apply ();
|
||||
void on_cancel ();
|
||||
bool on_delete_event (GdkEventAny*);
|
||||
|
@ -45,6 +45,14 @@ namespace ARDOUR {
|
||||
*/
|
||||
LIBARDOUR_API std::string user_cache_directory ();
|
||||
|
||||
/**
|
||||
* @return the path used to store a persistent indication
|
||||
* that the given version of the program has been used before.
|
||||
*
|
||||
* @param version is the version to check for. If unspecified,
|
||||
* it defaults to the current (build-time) version of the program.
|
||||
*/
|
||||
LIBARDOUR_API std::string been_here_before_path (int version = -1);
|
||||
|
||||
/**
|
||||
* @return the path to the directory that contains the system wide ardour
|
||||
|
@ -272,4 +272,15 @@ ardour_data_search_path ()
|
||||
return search_path;
|
||||
}
|
||||
|
||||
string
|
||||
been_here_before_path (int version)
|
||||
{
|
||||
if (version < 0) {
|
||||
version = atoi (PROGRAM_VERSION);
|
||||
}
|
||||
|
||||
return Glib::build_filename (user_config_directory (version), string (".a") + to_string (version, std::dec));
|
||||
}
|
||||
|
||||
|
||||
} // namespace ARDOUR
|
||||
|
Loading…
Reference in New Issue
Block a user