From 4a83c8cf7fadc162d1833dd5b9d3efde992308ae Mon Sep 17 00:00:00 2001 From: Phil Ruffwind Date: Fri, 20 Feb 2015 04:11:45 -0500 Subject: [PATCH] Fix isRealDirectory for Windows --- System/Directory.hs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/System/Directory.hs b/System/Directory.hs index da9db891..6002275c 100644 --- a/System/Directory.hs +++ b/System/Directory.hs @@ -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