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.
22 #include "pbd/error.h"
23 #include "pbd/compose.h"
24 #include "pbd/filesystem.h"
26 #include <glibmm/miscutils.h>
27 #include <glibmm/fileutils.h>
29 #include "ardour/directory_names.h"
30 #include "ardour/filesystem_paths.h"
41 user_config_directory ()
46 p = Glib::get_home_dir();
47 p /= "Library/Preferences";
52 /* adopt freedesktop standards, and put .ardour3 into $XDG_CONFIG_HOME or ~/.config
55 if ((c = getenv ("XDG_CONFIG_HOME")) != 0) {
58 const string home_dir = Glib::get_home_dir();
60 if (home_dir.empty ()) {
61 const string error_msg = "Unable to determine home directory";
64 error << error_msg << endmsg;
66 throw sys::filesystem_error(error_msg);
74 p /= user_config_dir_name;
76 std::string ps (p.to_string());
78 if (!Glib::file_test (ps, Glib::FILE_TEST_EXISTS)) {
79 if (g_mkdir_with_parents (ps.c_str(), 0755)) {
80 error << string_compose (_("Cannot create Configuration directory %1 - cannot run"),
84 } else if (!Glib::file_test (ps, Glib::FILE_TEST_IS_DIR)) {
85 error << string_compose (_("Configuration directory %1 already exists and is not a directory/folder - cannot run"),
94 ardour_dll_directory ()
96 std::string s = Glib::getenv("ARDOUR_DLL_PATH");
98 std::cerr << _("ARDOUR_DLL_PATH not set in environment - exiting\n");
105 ardour_config_search_path ()
107 static SearchPath search_path;
109 if (search_path.empty()) {
110 search_path += user_config_directory();
112 std::string s = Glib::getenv("ARDOUR_CONFIG_PATH");
114 std::cerr << _("ARDOUR_CONFIG_PATH not set in environment - exiting\n");
118 search_path += SearchPath (s);
125 ardour_data_search_path ()
127 static SearchPath search_path;
129 if (search_path.empty()) {
130 search_path += user_config_directory();
132 std::string s = Glib::getenv("ARDOUR_DATA_PATH");
134 std::cerr << _("ARDOUR_DATA_PATH not set in environment - exiting\n");
138 search_path += SearchPath (s);
144 } // namespace ARDOUR