From 8f70256c2e54e21df085786b69a8e74901aad7f2 Mon Sep 17 00:00:00 2001 From: Simon Marlow Date: Fri, 26 Feb 2010 09:31:44 +0000 Subject: [PATCH] Fix #3878: various directory tests were wrong on Unix systems --- System/Directory.hs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/System/Directory.hs b/System/Directory.hs index bd05bad..2f3cb25 100644 --- a/System/Directory.hs +++ b/System/Directory.hs @@ -203,7 +203,7 @@ getPermissions name = do write_ok <- Posix.fileAccess name False True False exec_ok <- Posix.fileAccess name False False True stat <- Posix.getFileStatus name - let is_dir = Posix.fileMode stat .&. Posix.directoryMode /= 0 + let is_dir = Posix.isDirectory stat return ( Permissions { readable = read_ok, @@ -373,7 +373,7 @@ createDirectoryIfMissing create_parents path0 else throw e #else stat <- Posix.getFileStatus dir - if Posix.fileMode stat .&. Posix.directoryMode /= 0 + if Posix.isDirectory stat then return () else throw e #endif @@ -618,7 +618,7 @@ renameFile opath npath = do is_dir <- isDirectory st #else stat <- Posix.getSymbolicLinkStatus opath - let is_dir = Posix.fileMode stat .&. Posix.directoryMode /= 0 + let is_dir = Posix.isDirectory stat #endif if is_dir then ioException (ioeSetErrorString @@ -898,7 +898,7 @@ doesDirectoryExist name = (withFileStatus "doesDirectoryExist" name $ \st -> isDirectory st) #else (do stat <- Posix.getFileStatus name - return (Posix.fileMode stat .&. Posix.directoryMode /= 0)) + return (Posix.isDirectory stat)) #endif `catch` ((\ _ -> return False) :: IOException -> IO Bool) @@ -912,7 +912,7 @@ doesFileExist name = (withFileStatus "doesFileExist" name $ \st -> do b <- isDirectory st; return (not b)) #else (do stat <- Posix.getFileStatus name - return (Posix.fileMode stat .&. Posix.directoryMode == 0)) + return (not (Posix.isDirectory stat))) #endif `catch` ((\ _ -> return False) :: IOException -> IO Bool) -- 1.7.10.4