#include "ardour/export_timespan.h"
#include "ardour/sndfile_helpers.h"
-#include "pbd/filesystem.h"
+#include "pbd/file_utils.h"
#include "pbd/cpus.h"
using namespace AudioGrapher;
{
while (filenames.size()) {
ExportFilenamePtr & filename = filenames.front();
- PBD::sys::copy_file (orig_path, filename->get_path (config.format).c_str());
+ PBD::copy_file (orig_path, filename->get_path (config.format).c_str());
filenames.pop_front();
}
}
#include "pbd/enumwriter.h"
#include "pbd/error.h"
#include "pbd/filesystem.h"
+#include "pbd/file_utils.h"
#include "pbd/pathscanner.h"
#include "pbd/pthread_utils.h"
#include "pbd/search_path.h"
/* Copy plugin state files from template to new session */
std::string template_plugins = Glib::build_filename (session_template, X_("plugins"));
- sys::copy_files (template_plugins, plugins_dir ());
+ copy_files (template_plugins, plugins_dir ());
return 0;
xmlpath.to_string(), backup_path.to_string(), PROGRAM_NAME)
<< endmsg;
- if (!sys::copy_file (xmlpath.to_string(), backup_path.to_string())) {;
+ if (!copy_file (xmlpath.to_string(), backup_path.to_string())) {;
return -1;
}
}
sys::path template_plugin_state_path = template_dir_path;
template_plugin_state_path /= X_("plugins");
sys::create_directories (template_plugin_state_path);
- sys::copy_files (plugins_dir(), template_plugin_state_path.to_string());
+ copy_files (plugins_dir(), template_plugin_state_path.to_string());
return 0;
}
bool
create_backup_file (const std::string & file_path)
{
- return sys::copy_file (file_path, file_path + backup_suffix);
+ return copy_file (file_path, file_path + backup_suffix);
}
void
#include <glibmm/miscutils.h>
#include <glibmm/pattern.h>
+#include <giomm/file.h>
+
#include "pbd/compose.h"
#include "pbd/file_utils.h"
-
#include "pbd/error.h"
+#include "pbd/pathscanner.h"
+
+#include "i18n.h"
using namespace std;
return true;
}
+bool
+copy_file(const std::string & from_path, const std::string & to_path)
+{
+ if (!Glib::file_test (from_path, Glib::FILE_TEST_EXISTS)) return false;
+
+ Glib::RefPtr<Gio::File> from_file = Gio::File::create_for_path(from_path);
+ Glib::RefPtr<Gio::File> to_file = Gio::File::create_for_path(to_path);
+
+ try
+ {
+ from_file->copy (to_file);
+ }
+ catch(const Glib::Exception& ex)
+ {
+ error << string_compose (_("Unable to Copy file %1 to %2 (%3)"),
+ from_path, to_path, ex.what())
+ << endmsg;
+ return false;
+ }
+ return true;
+}
+
+static
+bool accept_all_files (string const &, void *)
+{
+ return true;
+}
+
+void
+copy_files(const std::string & from_path, const std::string & to_dir)
+{
+ PathScanner scanner;
+ vector<string*>* files = scanner (from_path, accept_all_files, 0, true, false);
+ for (vector<string*>::iterator i = files->begin(); i != files->end(); ++i) {
+ std::string from = Glib::build_filename (from_path, **i);
+ std::string to = Glib::build_filename (to_dir, **i);
+ copy_file (from, to);
+ }
+}
+
} // namespace PBD
throw filesystem_error(g_strerror(errno), errno);
}
}
-
-bool
-copy_file(const std::string & from_path, const std::string & to_path)
-{
- if (!Glib::file_test (from_path, Glib::FILE_TEST_EXISTS)) return false;
-
- Glib::RefPtr<Gio::File> from_file = Gio::File::create_for_path(from_path);
- Glib::RefPtr<Gio::File> to_file = Gio::File::create_for_path(to_path);
-
- try
- {
- from_file->copy (to_file);
- }
- catch(const Glib::Exception& ex)
- {
- error << string_compose (_("Unable to Copy file %1 to %2 (%3)"),
- from_path, to_path, ex.what())
- << endmsg;
- return false;
- }
- return true;
-}
-
-static
-bool accept_all_files (string const &, void *)
-{
- return true;
-}
-void
-copy_files(const std::string & from_path, const std::string & to_dir)
-{
- PathScanner scanner;
- vector<string*>* files = scanner (from_path, accept_all_files, 0, true, false);
- for (vector<string*>::iterator i = files->begin(); i != files->end(); ++i) {
- std::string from = Glib::build_filename (from_path, **i);
- std::string to = Glib::build_filename (to_dir, **i);
- copy_file (from, to);
- }
-}
-
string
basename (const path & p)
{
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.
+ *
+ * @return true if file was successfully copied
+ */
+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.
+ */
+void copy_files(const std::string & from_path, const std::string & to_dir);
+
} // namespace PBD
#endif
*/
void rename (const path& from_path, const path& to_path);
-/**
- * Attempt to copy the contents of the file from_path to a new file
- * at path to_path.
- *
- * @return true if file was successfully copied
- */
-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.
- */
-void copy_files(const std::string & from_path, const std::string & to_dir);
-
/**
* @return The substring of the filename component of the path, starting
* at the beginning of the filename up to but not including the last dot.