From 03cc92646d3b2c49b850de0952aeaaf1ef863d7d Mon Sep 17 00:00:00 2001 From: Clemens Lang Date: Sun, 21 Sep 2014 17:45:01 +0200 Subject: Unify whitespace in System/Posix/Files/ByteString --- System/Posix/Files/ByteString.hsc | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'System') diff --git a/System/Posix/Files/ByteString.hsc b/System/Posix/Files/ByteString.hsc index 80f0bea..9430779 100644 --- a/System/Posix/Files/ByteString.hsc +++ b/System/Posix/Files/ByteString.hsc @@ -145,22 +145,22 @@ fileExist name = withFilePath 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 throwErrnoPath "fileExist" name + then return True + else do err <- getErrno + if (err == eNOENT) + then return False + else throwErrnoPath "fileExist" name access :: RawFilePath -> CMode -> IO Bool access name flags = withFilePath name $ \s -> do r <- c_access s (fromIntegral flags) if (r == 0) - then return True - else do err <- getErrno - if (err == eACCES) - then return False - else throwErrnoPath "fileAccess" name + then return True + else do err <- getErrno + if (err == eACCES) + then return False + else throwErrnoPath "fileAccess" name -- | @getFileStatus path@ calls gets the @FileStatus@ information (user ID, @@ -276,7 +276,7 @@ readSymbolicLink file = allocaArray0 (#const PATH_MAX) $ \buf -> do withFilePath file $ \s -> do len <- throwErrnoPathIfMinus1 "readSymbolicLink" file $ - c_readlink s buf (#const PATH_MAX) + c_readlink s buf (#const PATH_MAX) peekFilePathLen (buf,fromIntegral len) foreign import ccall unsafe "readlink" @@ -323,7 +323,7 @@ setSymbolicLinkOwnerAndGroup :: RawFilePath -> UserID -> GroupID -> IO () setSymbolicLinkOwnerAndGroup name uid gid = do withFilePath name $ \s -> throwErrnoPathIfMinus1_ "setSymbolicLinkOwnerAndGroup" name - (c_lchown s uid gid) + (c_lchown s uid gid) foreign import ccall unsafe "lchown" c_lchown :: CString -> CUid -> CGid -> IO CInt -- cgit v1.2.3 From 5c5484c8006f3df63d4cfb640f947f6391ea192f Mon Sep 17 00:00:00 2001 From: Clemens Lang Date: Sun, 21 Sep 2014 17:45:56 +0200 Subject: Unify accepted errno flags for access The ByteString variant of the access function didn't accept the same flags as the non-ByteString one, but it makes sense that the OS doesn't care about which one is being used and returns all error codes for both variants. --- System/Posix/Files/ByteString.hsc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'System') diff --git a/System/Posix/Files/ByteString.hsc b/System/Posix/Files/ByteString.hsc index 9430779..1b346a7 100644 --- a/System/Posix/Files/ByteString.hsc +++ b/System/Posix/Files/ByteString.hsc @@ -158,7 +158,7 @@ access name flags = if (r == 0) then return True else do err <- getErrno - if (err == eACCES) + if (err == eACCES || err == eROFS || err == eTXTBSY) then return False else throwErrnoPath "fileAccess" name -- cgit v1.2.3 From 3a0c0fe1c8b2242250735675b64114fadbfc0aee Mon Sep 17 00:00:00 2001 From: Clemens Lang Date: Sun, 21 Sep 2014 17:49:16 +0200 Subject: Accept EPERM as valid error code for access(2) This is useful on OS X when its sandboxing mechanism is used, because that will set errno = EPERM when a file can't be written due to sandboxing (as opposed to setting it to EACCES when file permissions deny writing). --- System/Posix/Files.hsc | 3 ++- System/Posix/Files/ByteString.hsc | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'System') diff --git a/System/Posix/Files.hsc b/System/Posix/Files.hsc index c8b5ddf..7c20987 100644 --- a/System/Posix/Files.hsc +++ b/System/Posix/Files.hsc @@ -152,7 +152,8 @@ access name flags = if (r == 0) then return True else do err <- getErrno - if (err == eACCES || err == eROFS || err == eTXTBSY) + if (err == eACCES || err == eROFS || err == eTXTBSY || + err == ePERM) then return False else throwErrnoPath "fileAccess" name diff --git a/System/Posix/Files/ByteString.hsc b/System/Posix/Files/ByteString.hsc index 1b346a7..dc1a3f8 100644 --- a/System/Posix/Files/ByteString.hsc +++ b/System/Posix/Files/ByteString.hsc @@ -158,7 +158,8 @@ access name flags = if (r == 0) then return True else do err <- getErrno - if (err == eACCES || err == eROFS || err == eTXTBSY) + if (err == eACCES || err == eROFS || err == eTXTBSY || + err == ePERM) then return False else throwErrnoPath "fileAccess" name -- cgit v1.2.3