]> git.lyx.org Git - lyx.git/blobdiff - src/support/rename.cpp
Introduce FileName::changePermission() and fix ConverterCache.
[lyx.git] / src / support / rename.cpp
index 45b1b45e861d339d77c4352fc14ae8a5cee69fc9..9a18e58a2dfed3230a29ee215dd90e9ca6ee310b 100644 (file)
 namespace lyx {
 namespace support {
 
-
-using std::string;
-
-
 bool rename(FileName const & from, FileName const & to)
 {
-       if (::rename(from.toFilesystemEncoding().c_str(), to.toFilesystemEncoding().c_str()) == -1)
-               if (copy(from, to)) {
-                       unlink(from);
-                       return true;
-               } else
-                       return false;
+       if (::rename(from.toFilesystemEncoding().c_str(),
+                       to.toFilesystemEncoding().c_str()) != -1) 
+               return true;
+       if (!copy(from, to))
+               return false;
+       from.removeFile();
        return true;
 }