ardour
file_utils.h
Go to the documentation of this file.
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/libpbd_visibility.h"
29 #include "pbd/search_path.h"
30 
31 namespace PBD {
32 
44 LIBPBD_API void
45 get_paths (std::vector<std::string>& result,
46  const Searchpath& paths,
47  bool files_only = true,
48  bool recurse = false);
49 
57 LIBPBD_API void
58 get_files (std::vector<std::string>& result,
59  const Searchpath& paths);
60 
69 LIBPBD_API void
70 find_files_matching_pattern (std::vector<std::string>& result,
71  const Searchpath& paths,
72  const Glib::PatternSpec& pattern);
73 
87 LIBPBD_API void
88 find_files_matching_pattern (std::vector<std::string>& result,
89  const Searchpath& paths,
90  const std::string& pattern);
91 
103 LIBPBD_API bool
104 find_file (const Searchpath& search_path,
105  const std::string& filename,
106  std::string& result);
107 
108 
117 LIBPBD_API void
118 find_files_matching_regex (std::vector<std::string>& results,
119  const Searchpath& paths,
120  const std::string& regexp,
121  bool recurse = false);
122 
135 LIBPBD_API void
136 find_paths_matching_filter (std::vector<std::string>& results,
137  const Searchpath& paths,
138  bool (*filter)(const std::string &, void *),
139  void *arg,
140  bool pass_fullpath,
141  bool return_fullpath,
142  bool recurse = false);
143 
156 LIBPBD_API void
157 find_files_matching_filter (std::vector<std::string>& results,
158  const Searchpath& paths,
159  bool (*filter)(const std::string &, void *),
160  void *arg,
161  bool pass_fullpath,
162  bool return_fullpath,
163  bool recurse = false);
164 
171 LIBPBD_API bool copy_file(const std::string & from_path, const std::string & to_path);
172 
177 LIBPBD_API void copy_files(const std::string & from_path, const std::string & to_dir);
178 
182 LIBPBD_API void copy_recurse(const std::string & from_path, const std::string & to_dir);
183 
188 LIBPBD_API std::string get_absolute_path (const std::string &);
189 
195 LIBPBD_API std::string get_suffix (const std::string &);
196 
202 LIBPBD_API bool path_is_within (const std::string &, std::string);
203 
211 LIBPBD_API bool equivalent_paths (const std::string &p1, const std::string &p2);
212 
214 LIBPBD_API bool exists_and_writable(const std::string & p);
215 
225 LIBPBD_API int clear_directory (const std::string& dir, size_t* size = 0,
226  std::vector<std::string>* removed_files = 0);
227 
234 LIBPBD_API void remove_directory (const std::string& dir);
235 
250 LIBPBD_API std::string tmp_writable_directory (const char* domain, const std::string& prefix);
251 
257 LIBPBD_API int toggle_file_existence (std::string const &);
258 
259 } // namespace PBD
260 
261 #endif
void find_paths_matching_filter(vector< string > &result, const Searchpath &paths, bool(*filter)(const string &, void *), void *arg, bool pass_fullpath, bool return_fullpath, bool recurse)
Definition: file_utils.cc:260
#define LIBPBD_API
void remove_directory(const std::string &dir)
Definition: file_utils.cc:465
bool path_is_within(std::string const &haystack, std::string needle)
Definition: file_utils.cc:375
void find_files_matching_regex(vector< string > &result, const Searchpath &paths, const std::string &regexp, bool recurse)
Definition: file_utils.cc:226
std::string get_suffix(const std::string &p)
Definition: file_utils.cc:354
bool find_file(const Searchpath &search_path, const string &filename, std::string &result)
Definition: file_utils.cc:187
int toggle_file_existence(string const &path)
Definition: file_utils.cc:488
int clear_directory(const string &dir, size_t *size, vector< string > *paths)
Definition: file_utils.cc:458
void copy_recurse(const std::string &from_path, const std::string &to_dir)
Definition: file_utils.cc:332
bool copy_file(const std::string &from_path, const std::string &to_path)
Definition: file_utils.cc:282
void find_files_matching_pattern(vector< string > &result, const Searchpath &paths, const Glib::PatternSpec &pattern)
Definition: file_utils.cc:168
string tmp_writable_directory(const char *domain, const string &prefix)
Definition: file_utils.cc:471
bool exists_and_writable(const std::string &p)
Definition: file_utils.cc:392
std::string get_absolute_path(const std::string &p)
Definition: file_utils.cc:347
void copy_files(const std::string &from_path, const std::string &to_dir)
Definition: file_utils.cc:319
void get_paths(vector< string > &result, const Searchpath &paths, bool files_only, bool recurse)
Definition: file_utils.cc:144
Definition: debug.h:30
void get_files(vector< string > &result, const Searchpath &paths)
Definition: file_utils.cc:154
bool equivalent_paths(const std::string &a, const std::string &b)
Definition: file_utils.cc:364
void find_files_matching_filter(vector< string > &result, const Searchpath &paths, bool(*filter)(const string &, void *), void *arg, bool pass_fullpath, bool return_fullpath, bool recurse)
Definition: file_utils.cc:271