#include <boost/bind.hpp>
#include <boost/filesystem/operations.hpp>
-#include <utime.h>
+#if defined (HAVE_UTIME_H)
+# include <utime.h>
+#elif defined (HAVE_SYS_UTIME_H)
+# include <sys/utime.h>
+#endif
#include <iomanip>
#include <stack>
filename));
return false;
}
- string command =
- "python " + LibFileSearch("lyx2lyx", "lyx2lyx");
- if (command.empty()) {
+ string const lyx2lyx = LibFileSearch("lyx2lyx", "lyx2lyx");
+ if (lyx2lyx.empty()) {
Alert::error(_("Conversion script not found"),
bformat(_("%1$s is from an earlier"
" version of LyX, but the"
filename));
return false;
}
- command += " -t"
- + convert<string>(LYX_FORMAT)
- + " -o " + tmpfile + ' '
- + QuoteName(filename);
+ ostringstream command;
+ command << "python " << QuoteName(lyx2lyx)
+ << " -t " << convert<string>(LYX_FORMAT)
+ << " -o " << QuoteName(tmpfile) << ' '
+ << QuoteName(filename);
+ string const command_str = command.str();
+
lyxerr[Debug::INFO] << "Running '"
- << command << '\''
+ << command_str << '\''
<< endl;
- cmd_ret const ret = RunCommand(command);
+
+ cmd_ret const ret = RunCommand(command_str);
if (ret.first != 0) {
Alert::error(_("Conversion script failed"),
bformat(_("%1$s is from an earlier version"
// good enough. (Lgb)
// But to use this we need fs::copy_file to actually do a copy,
// even when the target file exists. (Lgb)
- if (fs::exists(fileName())) {
+ if (fs::exists(fileName()) && fs::is_writable(fs::path(fileName()).branch_path())) {
//try {
fs::copy_file(fileName(), s, false);
//}