Ardour  9.0-pre0-350-gf17a656217
file_utils.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2007-2016 Tim Mayberry <mojofunk@gmail.com>
3  * Copyright (C) 2008-2015 Paul Davis <paul@linuxaudiosystems.com>
4  * Copyright (C) 2014-2015 Robin Gareus <robin@gareus.org>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19  */
20 
21 #ifndef PBD_FILE_UTILS_INCLUDED
22 #define PBD_FILE_UTILS_INCLUDED
23 
24 #include <string>
25 #include <vector>
26 
27 #include <glibmm/pattern.h>
28 
29 #include "pbd/libpbd_visibility.h"
30 #include "pbd/search_path.h"
31 
32 namespace PBD {
33 
45 LIBPBD_API void
46 get_paths (std::vector<std::string>& result,
47  const Searchpath& paths,
48  bool files_only = true,
49  bool recurse = false);
50 
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, bool preseve_timestamps = false);
183 
190 LIBPBD_API bool touch_file (const std::string& path);
191 
195 LIBPBD_API bool hard_link (const std::string& existing_file, const std::string& new_path);
196 
201 LIBPBD_API std::string get_absolute_path (const std::string &);
202 
207 LIBPBD_API std::string canonical_path (const std::string& path);
208 
214 LIBPBD_API std::string get_suffix (const std::string &);
215 
221 LIBPBD_API bool path_is_within (const std::string &, std::string);
222 
230 LIBPBD_API bool equivalent_paths (const std::string &p1, const std::string &p2);
231 
233 LIBPBD_API bool exists_and_writable(const std::string & p);
234 
244 LIBPBD_API int clear_directory (const std::string& dir, size_t* size = 0,
245  std::vector<std::string>* removed_files = 0);
246 
253 LIBPBD_API void remove_directory (const std::string& dir);
254 
269 LIBPBD_API std::string tmp_writable_directory (const char* domain, const std::string& prefix);
270 
275 LIBPBD_API int toggle_file_existence (std::string const & path);
276 
277 } // namespace PBD
278 
279 #endif
#define LIBPBD_API
Definition: axis_view.h:42
void find_files_matching_filter(std::vector< std::string > &results, const Searchpath &paths, bool(*filter)(const std::string &, void *), void *arg, bool pass_fullpath, bool return_fullpath, bool recurse=false)
void copy_files(const std::string &from_path, const std::string &to_dir)
bool path_is_within(const std::string &, std::string)
bool copy_file(const std::string &from_path, const std::string &to_path)
bool equivalent_paths(const std::string &p1, const std::string &p2)
std::string tmp_writable_directory(const char *domain, const std::string &prefix)
void get_files(std::vector< std::string > &result, const Searchpath &paths)
void find_files_matching_regex(std::vector< std::string > &results, const Searchpath &paths, const std::string &regexp, bool recurse=false)
std::string canonical_path(const std::string &path)
int clear_directory(const std::string &dir, size_t *size=0, std::vector< std::string > *removed_files=0)
bool hard_link(const std::string &existing_file, const std::string &new_path)
bool touch_file(const std::string &path)
void find_paths_matching_filter(std::vector< std::string > &results, const Searchpath &paths, bool(*filter)(const std::string &, void *), void *arg, bool pass_fullpath, bool return_fullpath, bool recurse=false)
bool exists_and_writable(const std::string &p)
void copy_recurse(const std::string &from_path, const std::string &to_dir, bool preseve_timestamps=false)
std::string get_suffix(const std::string &)
void get_paths(std::vector< std::string > &result, const Searchpath &paths, bool files_only=true, bool recurse=false)
void find_files_matching_pattern(std::vector< std::string > &result, const Searchpath &paths, const Glib::PatternSpec &pattern)
void remove_directory(const std::string &dir)
int toggle_file_existence(std::string const &path)
bool find_file(const Searchpath &search_path, const std::string &filename, std::string &result)
std::string get_absolute_path(const std::string &)