X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fmover.C;h=82cdce869b6bcaee4f1ea7c2ffaabe1b1e41a10e;hb=35204f8f33d7400a5fefeffea533fb4cb4097211;hp=20e590940852dadc6aa4ccf57bb8c27bbbe3803c;hpb=3b9338a3a8ba33fbbdf2c77cbffb3ff50d8fad86;p=lyx.git diff --git a/src/mover.C b/src/mover.C index 20e5909408..82cdce869b 100644 --- a/src/mover.C +++ b/src/mover.C @@ -17,21 +17,23 @@ #include "support/lyxlib.h" #include "support/systemcall.h" +#include #include -using std::ostringstream; -using std::string; -namespace support = lyx::support; +namespace lyx { + +using std::ios; +using std::string; Movers movers; Movers system_movers; bool Mover::do_copy(string const & from, string const & to, - string const &) const + string const &, unsigned long int mode) const { - return support::copy(from, to); + return support::copy(from, to, mode); } @@ -43,12 +45,21 @@ bool Mover::do_rename(string const & from, string const & to, bool SpecialisedMover::do_copy(string const & from, string const & to, - string const & latex) const + string const & latex, unsigned long int mode) const { if (command_.empty()) - return Mover::do_copy(from, to, latex); - - string command = support::LibScriptSearch(command_); + return Mover::do_copy(from, to, latex, mode); + + if (mode != (unsigned long int)-1) { + std::ofstream ofs(to.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", from); command = support::subst(command, "$$o", to); command = support::subst(command, "$$l", latex); @@ -64,7 +75,7 @@ bool SpecialisedMover::do_rename(string const & from, string const & to, if (command_.empty()) return Mover::do_rename(from, to, latex); - if (!do_copy(from, to, latex)) + if (!do_copy(from, to, latex, (unsigned long int)-1)) return false; return support::unlink(from) == 0; } @@ -88,3 +99,6 @@ string const Movers::command(string const & fmt) const SpecialsMap::const_iterator const it = specials_.find(fmt); return (it == specials_.end()) ? string() : it->second.command(); } + + +} // namespace lyx