Commit 9b4acb7d authored by Duncan Coutts's avatar Duncan Coutts
Browse files

Remove #ifdefery for windows, renameFile now works properly

It's even atomic on windows so we don't need the workaround.
parent 7fd30cb1
......@@ -180,9 +180,6 @@ import Distribution.Compat.CopyFile
import Distribution.Compat.TempFile
( openTempFile, openNewBinaryFile, createTempDirectory )
import Distribution.Compat.Exception (catchIO, onException)
#if mingw32_HOST_OS || mingw32_TARGET_OS
import Distribution.Compat.Exception (throwIOIO)
import Distribution.Verbosity
-- We only get our own version number when we're building with ourselves
......@@ -735,21 +732,7 @@ writeFileAtomic targetFile content = do
(tmpFile, tmpHandle) <- openNewBinaryFile targetDir template
do hPutStr tmpHandle content
hClose tmpHandle
#if mingw32_HOST_OS || mingw32_TARGET_OS
renameFile tmpFile targetFile
-- If the targetFile exists then renameFile will fail
`catchIO` \err -> do
exists <- doesFileExist targetFile
if exists
then do removeFile targetFile
-- Big fat hairy race condition
renameFile tmpFile targetFile
-- If the removeFile succeeds and the renameFile fails
-- then we've lost the atomic property.
else throwIOIO err
renameFile tmpFile targetFile
`onException` do hClose tmpHandle
removeFile tmpFile
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment