#4968: openTempFile fails on Windows if a directory exists with the file name it
tries
-------------------------------+--------------------------------------------
Reporter: ganesh | Owner:
Type: bug | Status: new
Priority: high | Milestone: 7.2.1
Component: libraries/base | Version: 7.0.1
Keywords: | Testcase:
Blockedby: | Difficulty:
Os: Windows | Blocking:
Architecture: x86_64 (amd64) | Failure: Incorrect result at runtime
-------------------------------+--------------------------------------------
Comment(by fryguybob):
The simplest thing to do would be
{{{
#!hs
if errno == eEXIST || errno == eACCES
}}}
But then `openTempFile` would not terminate if it didn't have write
access. So in the `eACCES` case we could check to see if the access
failure was due to a file or directory existing using something like:
{{{
#!hs
foreign import stdcall "windows.h GetFileAttributesA" c_GetFileAttributes
:: CString -> IO Word32
fileExists path = do
withCString path $ \p -> do
r <- c_GetFileAttributes p
return (r /= 0xFFFFFFFF)
}}}
I don't know if `base/System/IO.hs` is a good place for such things.
Windows does have a temp file name API ([http://msdn.microsoft.com/en-
us/library/aa364991(VS.85).aspx GetTempFileName]). But it doesn't quite
match the Haskell one as it forces a ".tmp" extension.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4968#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs