projects
/
haskell-directory.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
277a9e4
)
Fix #3878: various directory tests were wrong on Unix systems
author
Simon Marlow
<marlowsd@gmail.com>
Fri, 26 Feb 2010 09:31:44 +0000
(09:31 +0000)
committer
Simon Marlow
<marlowsd@gmail.com>
Fri, 26 Feb 2010 09:31:44 +0000
(09:31 +0000)
System/Directory.hs
patch
|
blob
|
history
diff --git
a/System/Directory.hs
b/System/Directory.hs
index
bd05bad
..
2f3cb25
100644
(file)
--- 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
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,
return (
Permissions {
readable = read_ok,
@@
-373,7
+373,7
@@
createDirectoryIfMissing create_parents path0
else throw e
#else
stat <- Posix.getFileStatus dir
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
then return ()
else throw e
#endif
@@
-618,7
+618,7
@@
renameFile opath npath = do
is_dir <- isDirectory st
#else
stat <- Posix.getSymbolicLinkStatus opath
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
#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
(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)
#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
(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)
#endif
`catch` ((\ _ -> return False) :: IOException -> IO Bool)