Skip to content

System.Directory.doesDirectoryExist "\\" is False on Windows

import System.Directory

main = do
   print =<< doesDirectoryExist "\\"
   print =<< doesDirectoryExist "\\."

The above prints False followed by True, and both should definitely be True. It seems like it might even be a bug in MinGW or the MSVCRT.

The following does work, giving both as True:

import Data.Bits
import System.Win32.Types
import System.Win32.File

doesDirectoryExist = flip withTString $ \s -> do
   a <- c_GetFileAttributes s
   return (a /= 0xffffffff && a.&.fILE_ATTRIBUTE_DIRECTORY /= 0)

main = do
   print =<< doesDirectoryExist "\\"
   print =<< doesDirectoryExist "\\."
Trac metadata
Trac field Value
Version 6.10.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component libraries/directory
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information