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"
25 #include <glibmm/miscutils.h>
26 #include <glibmm/fileutils.h>
28 #include "ardour/directory_names.h"
29 #include "ardour/filesystem_paths.h"
40 user_config_directory ()
45 p = Glib::build_filename (Glib::get_home_dir(), "Library/Preferences");
49 /* adopt freedesktop standards, and put .ardour3 into $XDG_CONFIG_HOME or ~/.config
52 if ((c = getenv ("XDG_CONFIG_HOME")) != 0) {
55 const string home_dir = Glib::get_home_dir();
57 if (home_dir.empty ()) {
58 error << "Unable to determine home directory" << endmsg;
63 p = Glib::build_filename (p, ".config");
67 p = Glib::build_filename (p, user_config_dir_name);
69 if (!Glib::file_test (p, Glib::FILE_TEST_EXISTS)) {
70 if (g_mkdir_with_parents (p.c_str(), 0755)) {
71 error << string_compose (_("Cannot create Configuration directory %1 - cannot run"),
75 } else if (!Glib::file_test (p, Glib::FILE_TEST_IS_DIR)) {
76 error << string_compose (_("Configuration directory %1 already exists and is not a directory/folder - cannot run"),
85 ardour_dll_directory ()
87 std::string s = Glib::getenv("ARDOUR_DLL_PATH");
89 std::cerr << _("ARDOUR_DLL_PATH not set in environment - exiting\n");
96 ardour_config_search_path ()
98 static SearchPath search_path;
100 if (search_path.empty()) {
101 search_path += user_config_directory();
103 std::string s = Glib::getenv("ARDOUR_CONFIG_PATH");
105 std::cerr << _("ARDOUR_CONFIG_PATH not set in environment - exiting\n");
109 search_path += SearchPath (s);
116 ardour_data_search_path ()
118 static SearchPath search_path;
120 if (search_path.empty()) {
121 search_path += user_config_directory();
123 std::string s = Glib::getenv("ARDOUR_DATA_PATH");
125 std::cerr << _("ARDOUR_DATA_PATH not set in environment - exiting\n");
129 search_path += SearchPath (s);
135 } // namespace ARDOUR