X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fpbd%2Fpbd%2Ffile_utils.h;h=01ff8606a722b0eda0d041812f569ed5ad60afe9;hb=e3329000557015ce54691235769db8821e75666b;hp=b303936fab8240e7559e56d16f279ab40fe12f1f;hpb=105caf23daf5aed16c7ee8b904fcca2ddbd4f59f;p=ardour.git diff --git a/libs/pbd/pbd/file_utils.h b/libs/pbd/pbd/file_utils.h index b303936fab..01ff8606a7 100644 --- a/libs/pbd/pbd/file_utils.h +++ b/libs/pbd/pbd/file_utils.h @@ -25,6 +25,7 @@ #include +#include "pbd/libpbd_visibility.h" #include "pbd/search_path.h" namespace PBD { @@ -37,7 +38,7 @@ namespace PBD { * @param path An Absolute path to a directory * @param result A vector of filenames. */ -void +LIBPBD_API void get_files_in_directory (const std::string& path, std::vector& result); @@ -49,7 +50,7 @@ get_files_in_directory (const std::string& path, * @param pattern A Glib::PatternSpec used to match the files. * @param result A vector in which to place the resulting matches. */ -void +LIBPBD_API void find_matching_files_in_directory (const std::string& directory, const Glib::PatternSpec& pattern, std::vector& result); @@ -62,21 +63,21 @@ find_matching_files_in_directory (const std::string& directory, * @param pattern A Glib::PatternSpec used to match the files * @param result A vector in which to place the resulting matches. */ -void +LIBPBD_API void find_matching_files_in_directories (const std::vector& directory_paths, const Glib::PatternSpec& pattern, std::vector& result); /** - * Takes a SearchPath and puts a list of all the files in the search path + * Takes a Searchpath and puts a list of all the files in the search path * that match pattern into the result vector. * - * @param search_path A SearchPath + * @param search_path A Searchpath * @param pattern A Glib::PatternSpec used to match the files * @param result A vector in which to place the resulting matches. */ -void -find_matching_files_in_search_path (const SearchPath& search_path, +LIBPBD_API void +find_matching_files_in_search_path (const Searchpath& search_path, const Glib::PatternSpec& pattern, std::vector& result); @@ -86,11 +87,50 @@ find_matching_files_in_search_path (const SearchPath& search_path, * * @return true If file is found within the search path. */ -bool -find_file_in_search_path (const SearchPath& search_path, +LIBPBD_API bool +find_file_in_search_path (const Searchpath& search_path, const std::string& filename, std::string& result); - + +/** + * Attempt to copy the contents of the file from_path to a new file + * at path to_path. If to_path exists it is overwritten. + * + * @return true if file was successfully copied + */ +LIBPBD_API bool copy_file(const std::string & from_path, const std::string & to_path); + +/** + * Attempt to copy all regular files from from_path to a new directory. + * This method does not recurse. + */ +LIBPBD_API void copy_files(const std::string & from_path, const std::string & to_dir); + +/** + * Take a (possibly) relative path and make it absolute + * @return An absolute path + */ +LIBPBD_API std::string get_absolute_path (const std::string &); + +/** + * Find out if `needle' is a file or directory within the + * directory `haystack'. + * @return true if it is. + */ +LIBPBD_API bool path_is_within (const std::string &, std::string); + +/** + * @return true if p1 and p2 both resolve to the same file + * @param p1 a file path. + * @param p2 a file path. + * + * Uses g_stat to check for identical st_dev and st_ino values. + */ +LIBPBD_API bool equivalent_paths (const std::string &p1, const std::string &p2); + +/// @return true if path at p exists and is writable, false otherwise +LIBPBD_API bool exists_and_writable(const std::string & p); + } // namespace PBD #endif