X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FMover.cpp;h=a901d98b0fa8fd025f13d26d4b1a93bfb412b5a5;hb=8fb1aa51f8d14747bd21d9e113a8dd301a2f07dc;hp=17cb7ba57a43fcdba7b74bce13d97c829c9572b4;hpb=7c392af6eab5e06a4836146859cbd9f2c3764420;p=lyx.git diff --git a/src/Mover.cpp b/src/Mover.cpp index 17cb7ba57a..a901d98b0f 100644 --- a/src/Mover.cpp +++ b/src/Mover.cpp @@ -12,9 +12,9 @@ #include "Mover.h" +#include "support/FileName.h" #include "support/filetools.h" #include "support/lstrings.h" -#include "support/lyxlib.h" #include "support/Systemcall.h" #include @@ -26,50 +26,40 @@ using namespace lyx::support; namespace lyx { -bool Mover::copy(FileName const & from, FileName const & to, - unsigned long int mode) const +bool Mover::copy(FileName const & from, FileName const & to) const { - return do_copy(from, to, to.absFilename(), mode); + return do_copy(from, to, to.absFileName()); } bool Mover::do_copy(FileName const & from, FileName const & to, - string const &, unsigned long int mode) const + string const &) const { - return copy(from, to, mode); + return from.copyTo(to); } bool Mover::rename(FileName const & from, FileName const & to) const { - return do_rename(from, to, to.absFilename()); + return do_rename(from, to, to.absFileName()); } bool Mover::do_rename(FileName const & from, FileName const & to, string const &) const { - return rename(from, to); + return from.moveTo(to); } bool SpecialisedMover::do_copy(FileName const & from, FileName const & to, - string const & latex, unsigned long int mode) const + string const & latex) const { if (command_.empty()) - return Mover::do_copy(from, to, latex, mode); - - if (mode != (unsigned long int)-1) { - ofstream ofs(to.toFilesystemEncoding().c_str(), ios::binary | ios::out | ios::trunc); - if (!ofs) - return false; - ofs.close(); - if (!chmod(to, mode)) - return false; - } - - string command = libScriptSearch(command_); + return Mover::do_copy(from, to, latex); + + string command = command_; command = subst(command, "$$i", quoteName(from.toFilesystemEncoding())); command = subst(command, "$$o", quoteName(to.toFilesystemEncoding())); command = subst(command, "$$l", quoteName(latex)); @@ -85,7 +75,7 @@ bool SpecialisedMover::do_rename(FileName const & from, FileName const & to, if (command_.empty()) return Mover::do_rename(from, to, latex); - if (!do_copy(from, to, latex, (unsigned long int)-1)) + if (!do_copy(from, to, latex)) return false; return from.removeFile(); }