Remove most using declarations from header files.
[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 using namespace PBD;
31
32 namespace ARDOUR {
33
34 using std::string;
35
36 sys::path
37 user_config_directory ()
38 {
39         const string home_dir = Glib::get_home_dir ();
40
41         if (home_dir.empty ()) {
42                 const string error_msg = "Unable to determine home directory";
43
44                 // log the error
45                 error << error_msg << endmsg;
46
47                 throw sys::filesystem_error(error_msg);
48         }
49
50         sys::path p(home_dir);
51         p /= user_config_dir_name;
52
53         return p;
54 }
55
56 sys::path
57 ardour_module_directory ()
58 {
59         sys::path module_directory(MODULE_DIR);
60         module_directory /= "ardour3";
61         return module_directory;
62 }
63
64 SearchPath
65 ardour_search_path ()
66 {
67         SearchPath spath_env(Glib::getenv("ARDOUR_PATH"));
68         return spath_env;
69 }
70
71 SearchPath
72 system_config_search_path ()
73 {
74 #ifdef WITH_STATIC_PATHS
75         SearchPath config_path(string(CONFIG_DIR));
76 #else
77         SearchPath config_path(system_config_directories());
78 #endif
79
80         config_path.add_subdirectory_to_paths("ardour3");
81
82         return config_path;
83 }
84
85 SearchPath
86 system_data_search_path ()
87 {
88 #ifdef WITH_STATIC_PATHS
89         SearchPath data_path(string(DATA_DIR));
90 #else
91         SearchPath data_path(system_data_directories());
92 #endif
93
94         data_path.add_subdirectory_to_paths("ardour3");
95
96         return data_path;
97 }
98
99 } // namespace ARDOUR