Ardour  9.2-266-g5d535d4cb7
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 #if defined(COMPILER_MSVC) && defined(WAF_BUILD)
33 #include <basetsd.h>
34 typedef SSIZE_T ssize_t; //Defining here for both file_utils.cc and file_archive.cc
35 #endif
36 
37 namespace PBD {
38 
50 LIBPBD_API void
51 get_paths (std::vector<std::string>& result,
52  const Searchpath& paths,
53  bool files_only = true,
54  bool recurse = false);
55 
62 LIBPBD_API void
63 get_files (std::vector<std::string>& result,
64  const Searchpath& paths);
65 
74 LIBPBD_API void
75 find_files_matching_pattern (std::vector<std::string>& result,
76  const Searchpath& paths,
77  const Glib::PatternSpec& pattern);
78 
92 LIBPBD_API void
93 find_files_matching_pattern (std::vector<std::string>& result,
94  const Searchpath& paths,
95  const std::string& pattern);
96 
108 LIBPBD_API bool
109 find_file (const Searchpath& search_path,
110  const std::string& filename,
111  std::string& result);
112 
113 
122 LIBPBD_API void
123 find_files_matching_regex (std::vector<std::string>& results,
124  const Searchpath& paths,
125  const std::string& regexp,
126  bool recurse = false);
127 
140 LIBPBD_API void
141 find_paths_matching_filter (std::vector<std::string>& results,
142  const Searchpath& paths,
143  bool (*filter)(const std::string &, void *),
144  void *arg,
145  bool pass_fullpath,
146  bool return_fullpath,
147  bool recurse = false);
148 
161 LIBPBD_API void
162 find_files_matching_filter (std::vector<std::string>& results,
163  const Searchpath& paths,
164  bool (*filter)(const std::string &, void *),
165  void *arg,
166  bool pass_fullpath,
167  bool return_fullpath,
168  bool recurse = false);
169 
176 LIBPBD_API bool copy_file(const std::string & from_path, const std::string & to_path);
177 
182 LIBPBD_API void copy_files(const std::string & from_path, const std::string & to_dir);
183 
187 LIBPBD_API void copy_recurse(const std::string & from_path, const std::string & to_dir, bool preseve_timestamps = false);
188 
195 LIBPBD_API bool touch_file (const std::string& path);
196 
200 LIBPBD_API bool hard_link (const std::string& existing_file, const std::string& new_path);
201 
206 LIBPBD_API std::string get_absolute_path (const std::string &);
207 
212 LIBPBD_API std::string canonical_path (const std::string& path);
213 
219 LIBPBD_API std::string get_suffix (const std::string &);
220 
226 LIBPBD_API bool path_is_within (const std::string &, std::string);
227 
235 LIBPBD_API bool equivalent_paths (const std::string &p1, const std::string &p2);
236 
238 LIBPBD_API bool exists_and_writable(const std::string & p);
239 
249 LIBPBD_API int clear_directory (const std::string& dir, size_t* size = 0,
250  std::vector<std::string>* removed_files = 0);
251 
258 LIBPBD_API void remove_directory (const std::string& dir);
259 
274 LIBPBD_API std::string tmp_writable_directory (const char* domain, const std::string& prefix);
275 
280 LIBPBD_API int toggle_file_existence (std::string const & path);
281 
282 } // namespace PBD
283 
284 #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 &)