瀏覽代碼

fix rename_to() on windows

David Rose 16 年之前
父節點
當前提交
5f0b8a9a6a
共有 1 個文件被更改,包括 9 次插入0 次删除
  1. 9 0
      dtool/src/dtoolutil/filename.cxx

+ 9 - 0
dtool/src/dtoolutil/filename.cxx

@@ -2430,6 +2430,15 @@ rename_to(const Filename &other) const {
     return true;
     return true;
   }
   }
 
 
+  // Try unlinking the target first.
+  other.unlink();
+  if (rename(temp_os_specific.c_str(),
+             other_os_specific.c_str()) == 0) {
+    // Successfully renamed.
+    unlink();
+    return true;
+  }
+
   // Failed.
   // Failed.
   temp.unlink();
   temp.unlink();
   return false;
   return false;