2 Copyright (C) 2007 Tim Mayberry
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include "pbd/error.h"
22 #include "pbd/compose.h"
23 #include "pbd/filesystem_paths.h"
25 #include <glibmm/miscutils.h>
26 #include <glibmm/fileutils.h>
28 #include "ardour/directory_names.h"
29 #include "ardour/filesystem_paths.h"
33 #define WITH_STATIC_PATHS 1
42 user_config_directory ()
47 p = Glib::get_home_dir();
48 p /= "Library/Preferences";
53 /* adopt freedesktop standards, and put .ardour3 into $XDG_CONFIG_HOME or ~/.config
56 if ((c = getenv ("XDG_CONFIG_HOME")) != 0) {
59 const string home_dir = Glib::get_home_dir();
61 if (home_dir.empty ()) {
62 const string error_msg = "Unable to determine home directory";
65 error << error_msg << endmsg;
67 throw sys::filesystem_error(error_msg);
75 p /= user_config_dir_name;
77 std::string ps (p.to_string());
79 if (!Glib::file_test (ps, Glib::FILE_TEST_EXISTS)) {
80 if (g_mkdir_with_parents (ps.c_str(), 0755)) {
81 error << string_compose (_("Cannot create Configuration directory %1 - cannot run"),
85 } else if (!Glib::file_test (ps, Glib::FILE_TEST_IS_DIR)) {
86 error << string_compose (_("Configuration directory %1 already exists and is not a directory/folder - cannot run"),
95 ardour_module_directory ()
97 sys::path module_directory(MODULE_DIR);
98 module_directory /= "ardour3";
99 return module_directory;
103 ardour_search_path ()
105 SearchPath spath_env(Glib::getenv("ARDOUR_PATH"));
110 system_config_search_path ()
112 #ifdef WITH_STATIC_PATHS
113 SearchPath config_path(string(CONFIG_DIR));
115 SearchPath config_path(system_config_directories());
118 config_path.add_subdirectory_to_paths("ardour3");
124 system_data_search_path ()
126 #ifdef WITH_STATIC_PATHS
127 SearchPath data_path(string(DATA_DIR));
129 SearchPath data_path(system_data_directories());
132 data_path.add_subdirectory_to_paths("ardour3");
137 } // namespace ARDOUR