Fix windows tempfile handling

On Windows, `ghc-mod lint` fails with following message.

    ghc-mod: DeleteFile "<Ommit>\\Temp\\ghc-mod-hlint8464": permission denied <Ommit>

Perhaps, On Windows, GHC opens file exclusively.
So, we move `removeFile` to `finally`.
This commit is contained in:
satoshi-murakumo 2014-04-16 14:45:14 +09:00
parent abb9ecd8ac
commit 0eadfa91fd

View File

@ -31,8 +31,9 @@ suppressStdout :: IO a -> IO a
suppressStdout f = do
tmpdir <- getTemporaryDirectory
(path, handle) <- openTempFile tmpdir "ghc-mod-hlint"
removeFile path
dup <- hDuplicate stdout
hDuplicateTo handle stdout
hClose handle
f `finally` hDuplicateTo dup stdout
f `finally` do
hDuplicateTo dup stdout
removeFile path