mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-07 07:14:56 +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
|
|
@ -23,10 +23,14 @@
|
|||
#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;
|
||||
|
||||
|
|
@ -125,4 +129,44 @@ find_file_in_search_path(const SearchPath& search_path,
|
|||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue