13
0

recursive file copy function

This commit is contained in:
Robin Gareus 2014-09-28 18:18:03 +02:00
parent b4438942ca
commit 6fbd0a62e4
2 changed files with 20 additions and 0 deletions

View File

@ -329,6 +329,21 @@ copy_files(const std::string & from_path, const std::string & to_dir)
}
}
void
copy_recurse(const std::string & from_path, const std::string & to_dir)
{
vector<string> files;
find_files_matching_filter (files, from_path, accept_all_files, 0, false, true, true);
const size_t prefix_len = from_path.size();
for (vector<string>::iterator i = files.begin(); i != files.end(); ++i) {
std::string from = *i;
std::string to = Glib::build_filename (to_dir, (*i).substr(prefix_len));
g_mkdir_with_parents (Glib::path_get_dirname (to).c_str(), 0755);
copy_file (from, to);
}
}
std::string
get_absolute_path (const std::string & p)
{

View File

@ -175,6 +175,11 @@ LIBPBD_API bool copy_file(const std::string & from_path, const std::string & to_
*/
LIBPBD_API void copy_files(const std::string & from_path, const std::string & to_dir);
/**
* Attempt to copy all regular files from from_path to a new directory.
*/
LIBPBD_API void copy_recurse(const std::string & from_path, const std::string & to_dir);
/**
* Take a (possibly) relative path and make it absolute
* @return An absolute path