- return Mover::do_copy(from, to, latex);
-
- string command = support::LibScriptSearch(command_);
- command = support::subst(command, "$$i", from);
- command = support::subst(command, "$$o", to);
- command = support::subst(command, "$$l", latex);
+ 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));