Remove unnecessary 0 checks before delete; see http://www.parashift.com/c++-faq-lite...
[ardour.git] / libs / ardour / template_utils.cc
1 #include <algorithm>
2
3 #include <pbd/filesystem.h>
4
5 #include <ardour/template_utils.h>
6 #include <ardour/directory_names.h>
7 #include <ardour/filesystem_paths.h>
8
9 namespace ARDOUR {
10
11 sys::path
12 system_template_directory ()
13 {
14         SearchPath spath(system_data_search_path());
15         spath.add_subdirectory_to_paths(templates_dir_name);
16
17         // just return the first directory in the search path that exists
18         SearchPath::const_iterator i = std::find_if(spath.begin(), spath.end(), sys::exists);
19
20         if (i == spath.end()) return sys::path();
21
22         return *i;
23 }
24
25 sys::path
26 user_template_directory ()
27 {
28         sys::path p(user_config_directory());
29         p /= templates_dir_name;
30
31         return p;
32 }
33
34 } // namespace ARDOUR