diff --git a/libs/pbd/file_utils.cc b/libs/pbd/file_utils.cc index 0877ceacbc..099d1be2d6 100644 --- a/libs/pbd/file_utils.cc +++ b/libs/pbd/file_utils.cc @@ -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 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::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) { diff --git a/libs/pbd/pbd/file_utils.h b/libs/pbd/pbd/file_utils.h index cb0aa38065..b266ad153f 100644 --- a/libs/pbd/pbd/file_utils.h +++ b/libs/pbd/pbd/file_utils.h @@ -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