Install everything to *ardour3* instead of *ardour2*.
[ardour.git] / libs / ardour / filesystem_paths.cc
1 /*
2     Copyright (C) 2007 Tim Mayberry 
3
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.
8
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.
13
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.
17
18 */
19
20 #include <pbd/error.h>
21 #include <pbd/filesystem_paths.h>
22
23 #include <glibmm/miscutils.h>
24
25 #include <ardour/directory_names.h>
26 #include <ardour/filesystem_paths.h>
27
28 #define WITH_STATIC_PATHS 1
29
30 namespace ARDOUR {
31
32 using std::string;
33
34 sys::path
35 user_config_directory ()
36 {
37         const string home_dir = Glib::get_home_dir ();
38
39         if (home_dir.empty ())
40         {
41                 const string error_msg = "Unable to determine home directory";
42
43                 // log the error
44                 error << error_msg << endmsg;
45
46                 throw sys::filesystem_error(error_msg);
47         }
48
49         sys::path p(home_dir);
50         p /= user_config_dir_name;
51
52         return p;
53 }
54
55 sys::path
56 ardour_module_directory ()
57 {
58         sys::path module_directory(MODULE_DIR);
59         module_directory /= "ardour3";
60         return module_directory;
61 }
62
63 SearchPath
64 ardour_search_path ()
65 {
66         SearchPath spath_env(Glib::getenv("ARDOUR_PATH"));
67         return spath_env;
68 }
69
70 SearchPath
71 system_config_search_path ()
72 {
73 #ifdef WITH_STATIC_PATHS
74
75         SearchPath config_path(string(CONFIG_DIR));
76
77 #else
78
79         SearchPath config_path(system_config_directories());
80
81 #endif
82
83         config_path.add_subdirectory_to_paths("ardour3");
84
85         return config_path;
86 }
87
88 SearchPath
89 system_data_search_path ()
90 {
91 #ifdef WITH_STATIC_PATHS
92
93         SearchPath data_path(string(DATA_DIR));
94
95 #else
96
97         SearchPath data_path(system_data_directories());
98
99 #endif
100
101         data_path.add_subdirectory_to_paths("ardour3");
102
103         return data_path;
104 }
105
106 } // namespace ARDOUR