Replace code for finding ControlProtocols/Surface plugins with a portable equivalent.
[ardour.git] / libs / pbd / pbd / file_utils.h
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 #ifndef PBD_FILE_UTILS_INCLUDED
21 #define PBD_FILE_UTILS_INCLUDED
22
23 #include <string>
24 #include <vector>
25
26 #include <glibmm/pattern.h>
27
28 #include <pbd/search_path.h>
29
30 namespace PBD {
31
32 using std::string;
33 using std::vector;
34
35 /**
36  * Get a list of files in a directory.
37  * @note You must join path with result to get the absolute path
38  * to the file.
39  *
40  * @param path An Absolute path to a directory
41  * @param result A vector of filenames.
42  */
43 void
44 get_files_in_directory (const sys::path& path,
45                         vector<string>& result);
46
47 /**
48  * Takes a directory path and returns all the files in the directory
49  * matching a particular pattern.
50  *
51  * @param directory A directory path
52  * @param pattern A Glib::PatternSpec used to match the files.
53  * @param result A vector in which to place the resulting matches.
54  */
55 void
56 find_matching_files_in_directory (const sys::path& directory,
57                                   const Glib::PatternSpec& pattern,
58                                   vector<sys::path>& result);
59
60 /**
61  * Takes a number of directory paths and returns all the files matching
62  * a particular pattern.
63  *
64  * @param paths A vector containing the Absolute paths
65  * @param pattern A Glib::PatternSpec used to match the files
66  * @param result A vector in which to place the resulting matches.
67  */
68 void
69 find_matching_files_in_directories (const vector<sys::path>& directory_paths,
70                                     const Glib::PatternSpec& pattern,
71                                     vector<sys::path>& result);
72
73 /**
74  * Takes a SearchPath and puts a list of all the files in the search path
75  * that match pattern into the result vector.
76  *
77  * @param search_path A SearchPath
78  * @param pattern A Glib::PatternSpec used to match the files
79  * @param result A vector in which to place the resulting matches.
80  */
81 void
82 find_matching_files_in_search_path (const SearchPath& search_path,
83                                     const Glib::PatternSpec& pattern,
84                                     vector<sys::path>& result);
85
86 /**
87  * Takes a search path and a file name and place the full path
88  * to that file in result if it is found within the search path.
89  *
90  * @return true If file is found within the search path.
91  */
92 bool
93 find_file_in_search_path (const SearchPath& search_path,
94                           const string& filename,
95                           sys::path& result);
96                         
97 } // namespace PBD
98
99 #endif