From 5f0b8a9a6a6cf7c735a1f0c8220fee3eeec3c3cf Mon Sep 17 00:00:00 2001 From: David Rose Date: Wed, 26 Aug 2009 22:56:56 +0000 Subject: [PATCH] fix rename_to() on windows --- dtool/src/dtoolutil/filename.cxx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/dtool/src/dtoolutil/filename.cxx b/dtool/src/dtoolutil/filename.cxx index c64f616cfb..b2ced9d25a 100644 --- a/dtool/src/dtoolutil/filename.cxx +++ b/dtool/src/dtoolutil/filename.cxx @@ -2430,6 +2430,15 @@ rename_to(const Filename &other) const { 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. temp.unlink(); return false;