X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FMover.cpp;h=a901d98b0fa8fd025f13d26d4b1a93bfb412b5a5;hb=cf14e814124ccbc8155fa1dde98d03be319c0e87;hp=b989cf118e147265dac58311bd7e5df608608eea;hpb=9383f4c3c6f9cfab2d658701ba66e2b54cd68bea;p=lyx.git diff --git a/src/Mover.cpp b/src/Mover.cpp index b989cf118e..a901d98b0f 100644 --- a/src/Mover.cpp +++ b/src/Mover.cpp @@ -12,80 +12,70 @@ #include "Mover.h" +#include "support/FileName.h" #include "support/filetools.h" #include "support/lstrings.h" -#include "support/lyxlib.h" #include "support/Systemcall.h" #include #include using namespace std; +using namespace lyx::support; namespace lyx { -using support::quoteName; -bool Mover::copy(support::FileName const & from, support::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(support::FileName const & from, support::FileName const & to, - string const &, unsigned long int mode) const +bool Mover::do_copy(FileName const & from, FileName const & to, + string const &) const { - return support::copy(from, to, mode); + return from.copyTo(to); } -bool Mover::rename(support::FileName const & from, - support::FileName const & to) const +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(support::FileName const & from, support::FileName const & to, +bool Mover::do_rename(FileName const & from, FileName const & to, string const &) const { - return support::rename(from, to); + return from.moveTo(to); } -bool SpecialisedMover::do_copy(support::FileName const & from, support::FileName const & to, - string const & latex, unsigned long int mode) const +bool SpecialisedMover::do_copy(FileName const & from, FileName const & to, + string const & latex) const { if (command_.empty()) - return Mover::do_copy(from, to, latex, mode); - - if (mode != (unsigned long int)-1) { - std::ofstream ofs(to.toFilesystemEncoding().c_str(), ios::binary | ios::out | ios::trunc); - if (!ofs) - return false; - ofs.close(); - if (!support::chmod(to, mode)) - return false; - } - - string command = support::libScriptSearch(command_); - command = support::subst(command, "$$i", quoteName(from.toFilesystemEncoding())); - command = support::subst(command, "$$o", quoteName(to.toFilesystemEncoding())); - command = support::subst(command, "$$l", quoteName(latex)); - - support::Systemcall one; - return one.startscript(support::Systemcall::Wait, command) == 0; + 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)); + + Systemcall one; + return one.startscript(Systemcall::Wait, command) == 0; } -bool SpecialisedMover::do_rename(support::FileName const & from, support::FileName const & to, +bool SpecialisedMover::do_rename(FileName const & from, FileName const & to, string const & latex) const { 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(); }