Skip to content

Commit

Permalink
Fix isRealDirectory for Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Rufflewind committed Feb 20, 2015
1 parent 40ade8e commit 4a83c8c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions System/Directory.hs
Original file line number Diff line number Diff line change
Expand Up @@ -493,10 +493,12 @@ removeContentsRecursive path =
-- | @'isRealDirectory path'@ checks whether /path/ refers to an actual
-- directory, i.e. not a symbolic link to another directory.
isRealDirectory :: FilePath -> IO Bool
isRealDirectory path =
isRealDirectory path = (`ioeSetLocation` "isRealDirectory") `modifyIOError` do
#ifdef mingw32_HOST_OS
-- ToDo: use Win32 API
withFileOrSymlinkStatus "" path isDirectory
attr <- Win32.getFileAttributes path
return (attr .&. Win32.fILE_ATTRIBUTE_DIRECTORY /= 0 &&
attr .&. fILE_ATTRIBUTE_REPARSE_POINT == 0)
where fILE_ATTRIBUTE_REPARSE_POINT = 0x400
#else
Posix.isDirectory `fmap` Posix.getSymbolicLinkStatus path
#endif
Expand Down

0 comments on commit 4a83c8c

Please sign in to comment.