13
0

hide user_config_dir_name; alter API for user_config_dir() to allow specification of a version number

This commit is contained in:
Paul Davis 2015-03-11 10:30:42 -05:00
parent 99260742d2
commit 1644fc1068
4 changed files with 29 additions and 16 deletions

View File

@ -40,7 +40,6 @@ namespace ARDOUR {
LIBARDOUR_API extern const char* const route_templates_dir_name;
LIBARDOUR_API extern const char* const surfaces_dir_name;
LIBARDOUR_API extern const char* const ladspa_dir_name;
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;

View File

@ -27,11 +27,16 @@
namespace ARDOUR {
/**
* @return the path to the directory used to store user specific ardour
* configuration files.
* @return the path to the directory used to store user specific
* configuration files for the given @param version of the program.
* If @param version is negative, the build-time string PROGRAM_VERSION
* will be used to determine the version number.
*
* @post user_config_directory() exists
*
*
*/
LIBARDOUR_API std::string user_config_directory ();
LIBARDOUR_API std::string user_config_directory (int version = -1);
/**
* @return the path to the directory used to store user specific

View File

@ -40,12 +40,4 @@ const char* const ladspa_dir_name = X_("ladspa");
const char* const panner_dir_name = X_("panners");
const char* const backend_dir_name = X_("backends");
char config_dir_name[] = X_(PROGRAM_NAME PROGRAM_VERSION);
#if defined (__APPLE__) || defined (PLATFORM_WINDOWS)
const char* const user_config_dir_name = config_dir_name;
#else
#include "pbd/convert.h"
const char* const user_config_dir_name = PBD::downcase (config_dir_name);
#endif
}

View File

@ -19,8 +19,9 @@
#include <cstdlib>
#include <iostream>
#include "pbd/error.h"
#include "pbd/compose.h"
#include "pbd/convert.h"
#include "pbd/error.h"
#include <glibmm/miscutils.h>
#include <glibmm/fileutils.h>
@ -41,8 +42,24 @@ namespace ARDOUR {
using std::string;
static std::string
user_config_directory_name (int version = -1)
{
if (version < 0) {
version = atoi (X_(PROGRAM_VERSION));
}
const string config_dir_name = string_compose ("%1%2", X_(PROGRAM_NAME), version);
#if defined (__APPLE__) || defined (PLATFORM_WINDOWS)
return config_dir_name;
#else
return downcase (config_dir_name);
#endif
}
std::string
user_config_directory ()
user_config_directory (int version)
{
static std::string p;
@ -79,7 +96,7 @@ user_config_directory ()
}
#endif // end not __APPLE__
p = Glib::build_filename (p, user_config_dir_name);
p = Glib::build_filename (p, user_config_directory_name (version));
if (!Glib::file_test (p, Glib::FILE_TEST_EXISTS)) {
if (g_mkdir_with_parents (p.c_str(), 0755)) {
@ -134,7 +151,7 @@ user_cache_directory ()
}
#endif // end not __APPLE__
p = Glib::build_filename (p, user_config_dir_name);
p = Glib::build_filename (p, user_config_directory_name ());
#ifdef PLATFORM_WINDOWS
/* On Windows Glib::get_user_data_dir is the folder to use for local