]> git.lyx.org Git - lyx.git/blobdiff - src/support/rename.C
another safety belt
[lyx.git] / src / support / rename.C
index 3f9324679124371dbb157bf81996e703b1b0ea7c..7c079a2100eb2bbcd2d683491e382f8cc7265aa4 100644 (file)
@@ -1,10 +1,19 @@
 #include <config.h>
 
-#include <stdio.h>
+#include <cstdio>
 
 #include "support/lyxlib.h"
 
-bool lyx::rename(char const * from, char const * to)
+bool lyx::rename(string const & from, string const & to)
 {
-       return ::rename(from, to) != -1;
+#ifdef __EMX__
+       lyx::unlink(to.c_str());
+#endif
+       if (::rename(from.c_str(), to.c_str()) == -1)
+               if (lyx::copy(from, to)) {
+                       lyx::unlink(from);
+                       return true;
+               } else
+                       return false;
+       return true;
 }