mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-08 15:54:57 +01:00
Move PBD::sys::copy_file/s into pbd/file_utils.h and PBD:: namespace
Copy files no longer depends on PBD::sys::path so move it git-svn-id: svn://localhost/ardour2/branches/3.0@12853 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
4cda435203
commit
a22dd8c20a
7 changed files with 67 additions and 62 deletions
|
|
@ -18,7 +18,7 @@
|
||||||
#include "ardour/export_timespan.h"
|
#include "ardour/export_timespan.h"
|
||||||
#include "ardour/sndfile_helpers.h"
|
#include "ardour/sndfile_helpers.h"
|
||||||
|
|
||||||
#include "pbd/filesystem.h"
|
#include "pbd/file_utils.h"
|
||||||
#include "pbd/cpus.h"
|
#include "pbd/cpus.h"
|
||||||
|
|
||||||
using namespace AudioGrapher;
|
using namespace AudioGrapher;
|
||||||
|
|
@ -216,7 +216,7 @@ ExportGraphBuilder::Encoder::copy_files (std::string orig_path)
|
||||||
{
|
{
|
||||||
while (filenames.size()) {
|
while (filenames.size()) {
|
||||||
ExportFilenamePtr & filename = filenames.front();
|
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();
|
filenames.pop_front();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,7 @@
|
||||||
#include "pbd/enumwriter.h"
|
#include "pbd/enumwriter.h"
|
||||||
#include "pbd/error.h"
|
#include "pbd/error.h"
|
||||||
#include "pbd/filesystem.h"
|
#include "pbd/filesystem.h"
|
||||||
|
#include "pbd/file_utils.h"
|
||||||
#include "pbd/pathscanner.h"
|
#include "pbd/pathscanner.h"
|
||||||
#include "pbd/pthread_utils.h"
|
#include "pbd/pthread_utils.h"
|
||||||
#include "pbd/search_path.h"
|
#include "pbd/search_path.h"
|
||||||
|
|
@ -540,7 +541,7 @@ Session::create (const string& session_template, BusProfile* bus_profile)
|
||||||
|
|
||||||
/* Copy plugin state files from template to new session */
|
/* Copy plugin state files from template to new session */
|
||||||
std::string template_plugins = Glib::build_filename (session_template, X_("plugins"));
|
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;
|
return 0;
|
||||||
|
|
||||||
|
|
@ -943,7 +944,7 @@ Session::load_state (string snapshot_name)
|
||||||
xmlpath.to_string(), backup_path.to_string(), PROGRAM_NAME)
|
xmlpath.to_string(), backup_path.to_string(), PROGRAM_NAME)
|
||||||
<< endmsg;
|
<< endmsg;
|
||||||
|
|
||||||
if (!sys::copy_file (xmlpath.to_string(), backup_path.to_string())) {;
|
if (!copy_file (xmlpath.to_string(), backup_path.to_string())) {;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2069,7 +2070,7 @@ Session::save_template (string template_name)
|
||||||
sys::path template_plugin_state_path = template_dir_path;
|
sys::path template_plugin_state_path = template_dir_path;
|
||||||
template_plugin_state_path /= X_("plugins");
|
template_plugin_state_path /= X_("plugins");
|
||||||
sys::create_directories (template_plugin_state_path);
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ namespace ARDOUR {
|
||||||
bool
|
bool
|
||||||
create_backup_file (const std::string & file_path)
|
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
|
void
|
||||||
|
|
|
||||||
|
|
@ -23,10 +23,14 @@
|
||||||
#include <glibmm/miscutils.h>
|
#include <glibmm/miscutils.h>
|
||||||
#include <glibmm/pattern.h>
|
#include <glibmm/pattern.h>
|
||||||
|
|
||||||
|
#include <giomm/file.h>
|
||||||
|
|
||||||
#include "pbd/compose.h"
|
#include "pbd/compose.h"
|
||||||
#include "pbd/file_utils.h"
|
#include "pbd/file_utils.h"
|
||||||
|
|
||||||
#include "pbd/error.h"
|
#include "pbd/error.h"
|
||||||
|
#include "pbd/pathscanner.h"
|
||||||
|
|
||||||
|
#include "i18n.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|
@ -125,4 +129,44 @@ find_file_in_search_path(const SearchPath& search_path,
|
||||||
return true;
|
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
|
} // namespace PBD
|
||||||
|
|
|
||||||
|
|
@ -185,46 +185,6 @@ rename (const path & from_path, const path & to_path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
string
|
||||||
basename (const path & p)
|
basename (const path & p)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -91,6 +91,20 @@ find_file_in_search_path (const SearchPath& search_path,
|
||||||
const std::string& filename,
|
const std::string& filename,
|
||||||
std::string& result);
|
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
|
} // namespace PBD
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -169,20 +169,6 @@ bool remove(const path & p);
|
||||||
*/
|
*/
|
||||||
void rename (const path& from_path, const path& to_path);
|
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
|
* @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.
|
* at the beginning of the filename up to but not including the last dot.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue