diff options
author | simonmar <unknown> | 2003-09-16 13:45:02 +0000 |
---|---|---|
committer | simonmar <unknown> | 2003-09-16 13:45:02 +0000 |
commit | ea8b6c17bee53bdaf26a7f72fc73eb6569f60b78 (patch) | |
tree | a5d38d7449cd44661bb4054785418a98a108fbc1 /System/Posix/Files.hsc | |
parent | 9a9842f47af4488ce71a296026be1e3f3c739e6a (diff) |
[project @ 2003-09-16 13:45:02 by simonmar]
fileExist should not throw an exception if the file does not exist.
Diffstat (limited to 'System/Posix/Files.hsc')
-rw-r--r-- | System/Posix/Files.hsc | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/System/Posix/Files.hsc b/System/Posix/Files.hsc index c66b9a9..010bf4e 100644 --- a/System/Posix/Files.hsc +++ b/System/Posix/Files.hsc @@ -196,7 +196,15 @@ fileAccess name read write exec = access name flags exec_f = if exec then (#const X_OK) else 0 fileExist :: FilePath -> IO Bool -fileExist name = access name (#const F_OK) +fileExist name = + withCString name $ \s -> do + r <- c_access s (#const F_OK) + if (r == 0) + then return True + else do err <- getErrno + if (err == eNOENT) + then return False + else throwErrno "fileExist" access :: FilePath -> CMode -> IO Bool access name flags = |