]> git.lyx.org Git - lyx.git/blobdiff - src/mover.C
hopefully fix tex2lyx linking.
[lyx.git] / src / mover.C
index 24950a870691af7de9cd53dc9be1f0402acd73ac..82cdce869b6bcaee4f1ea7c2ffaabe1b1e41a10e 100644 (file)
 #include "support/lyxlib.h"
 #include "support/systemcall.h"
 
+#include <fstream>
 #include <sstream>
 
 
 namespace lyx {
 
+using std::ios;
 using std::string;
 
 Movers movers;
@@ -29,9 +31,9 @@ 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,10 +45,19 @@ 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);
+               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);
@@ -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;
 }