26 #include <glibmm/miscutils.h>
27 #include <glibmm/fileutils.h>
34 #ifdef PLATFORM_WINDOWS
49 version =
atoi (
X_(PROGRAM_VERSION));
52 const string config_dir_name =
string_compose (
"%1%2",
X_(PROGRAM_NAME), version);
54 #if defined (__APPLE__) || defined (PLATFORM_WINDOWS)
55 return config_dir_name;
68 p = Glib::build_filename (Glib::get_home_dir(),
"Library/Preferences");
74 if ((c = getenv (
"XDG_CONFIG_HOME")) != 0) {
78 #ifdef PLATFORM_WINDOWS
80 const string home_dir = Glib::get_user_config_dir();
82 const string home_dir = Glib::get_home_dir();
84 if (home_dir.empty ()) {
85 error <<
"Unable to determine home directory" <<
endmsg;
90 #ifndef PLATFORM_WINDOWS
91 p = Glib::build_filename (p,
".config");
95 #endif // end not __APPLE__
103 if (!Glib::file_test (p, Glib::FILE_TEST_EXISTS)) {
104 if (g_mkdir_with_parents (p.c_str(), 0755)) {
109 }
else if (!Glib::file_test (p, Glib::FILE_TEST_IS_DIR)) {
110 error <<
string_compose (
_(
"Configuration directory %1 already exists and is not a directory/folder - cannot run"),
122 static std::string p;
124 if (!p.empty())
return p;
127 p = Glib::build_filename (Glib::get_home_dir(),
"Library/Caches");
134 if ((c = getenv (
"XDG_CACHE_HOME")) != 0) {
138 #ifdef PLATFORM_WINDOWS
140 const string home_dir = Glib::get_user_data_dir();
142 const string home_dir = Glib::get_home_dir();
144 if (home_dir.empty ()) {
145 error <<
"Unable to determine home directory" <<
endmsg;
150 #ifndef PLATFORM_WINDOWS
151 p = Glib::build_filename (p,
".cache");
155 #endif // end not __APPLE__
159 #ifdef PLATFORM_WINDOWS
166 p = Glib::build_filename (p,
"cache");
169 if (!Glib::file_test (p, Glib::FILE_TEST_EXISTS)) {
170 if (g_mkdir_with_parents (p.c_str(), 0755)) {
175 }
else if (!Glib::file_test (p, Glib::FILE_TEST_IS_DIR)) {
176 error <<
string_compose (
_(
"Cache directory %1 already exists and is not a directory/folder - cannot run"),
187 #ifdef PLATFORM_WINDOWS
188 std::string dll_dir_path(g_win32_get_package_installation_directory_of_module(NULL));
189 dll_dir_path = Glib::build_filename (dll_dir_path,
"lib");
190 return Glib::build_filename (dll_dir_path, LIBARDOUR);
192 std::string s = Glib::getenv(
"ARDOUR_DLL_PATH");
194 std::cerr <<
_(
"ARDOUR_DLL_PATH not set in environment - exiting\n");
201 #ifdef PLATFORM_WINDOWS
203 windows_search_path ()
205 std::string dll_dir_path(g_win32_get_package_installation_directory_of_module(NULL));
206 dll_dir_path = Glib::build_filename (dll_dir_path,
"share");
207 return Glib::build_filename (dll_dir_path, LIBARDOUR);
216 if (search_path.empty()) {
219 #ifdef PLATFORM_WINDOWS
222 const gchar*
const *all_users_folder = g_get_system_config_dirs();
226 if (all_users_folder) {
227 std::string writable_all_users_path = all_users_folder[0];
228 writable_all_users_path +=
"\\";
229 writable_all_users_path += PROGRAM_NAME;
230 writable_all_users_path +=
"\\.config";
232 writable_all_users_path +=
"\\win64";
234 writable_all_users_path +=
"\\win32";
236 search_path += writable_all_users_path;
240 search_path += windows_search_path ();
243 std::string s = Glib::getenv(
"ARDOUR_CONFIG_PATH");
245 std::cerr <<
_(
"ARDOUR_CONFIG_PATH not set in environment\n");
259 if (search_path.empty()) {
261 #ifdef PLATFORM_WINDOWS
262 search_path += windows_search_path ();
264 std::string s = Glib::getenv(
"ARDOUR_DATA_PATH");
266 std::cerr <<
_(
"ARDOUR_DATA_PATH not set in environment\n");
279 version =
atoi (PROGRAM_VERSION);
std::string to_string(T t, std::ios_base &(*f)(std::ios_base &))
int atoi(const string &s)
static std::string user_config_directory_name(int version=-1)
LIBPBD_API Transmitter error
std::ostream & endmsg(std::ostream &ostr)
string downcase(const string &str)
LIBARDOUR_API std::string user_config_directory(int version=-1)
LIBARDOUR_API std::string ardour_dll_directory()
LIBARDOUR_API std::string been_here_before_path(int version=-1)
LIBARDOUR_API PBD::Searchpath ardour_config_search_path()
LIBARDOUR_API std::string user_cache_directory()
LIBARDOUR_API PBD::Searchpath ardour_data_search_path()
std::string string_compose(const std::string &fmt, const T1 &o1)