From: Francois Pichet Date: Mon, 20 Sep 2010 04:03:07 +0000 (+0000) Subject: Fix the "unable to rename temporary" lit test failing on Windows. rename is now copy... X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=345adbe5726d3110e1e067842115b1b1472e0a7e;p=oota-llvm.git Fix the "unable to rename temporary" lit test failing on Windows. rename is now copy + delete on Windows. Problem to be revisited for a permanent and clean solution. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@114320 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/System/Win32/Path.inc b/lib/System/Win32/Path.inc index 4a6dbd3ddf2..64e7025fc9b 100644 --- a/lib/System/Win32/Path.inc +++ b/lib/System/Win32/Path.inc @@ -745,12 +745,19 @@ bool Path::getMagicNumber(std::string& Magic, unsigned len) const { return true; } +// Implements renamePathOnDisk as a CopyFile + eraseFromDisk on Windows. +// Using MoveFileEx was causing mysterious ACCESS_DENIED error when used +// within a multithreaded lit/python context. +// FIXME: put back MoveFileEx when the source of the problem is resolved. bool Path::renamePathOnDisk(const Path& newName, std::string* ErrMsg) { - if (!MoveFileEx(path.c_str(), newName.c_str(), MOVEFILE_REPLACE_EXISTING)) - return MakeErrMsg(ErrMsg, "Can't move '" + path + "' to '" + newName.path - + "': "); - return false; + if (*this == newName) + return false; + + if (CopyFile(newName, *this, ErrMsg)) + return true; + + return eraseFromDisk(true, ErrMsg); } bool