diff options
author | Herbert Valerio Riedel <hvr@gnu.org> | 2014-11-07 11:16:25 +0100 |
---|---|---|
committer | Herbert Valerio Riedel <hvr@gnu.org> | 2014-11-07 11:16:25 +0100 |
commit | f5a08a97292fe2f17df7320e47dd0272c382d811 (patch) | |
tree | 4c28ce003fbd3f00d4c48299dcfa9847116a24fb /System | |
parent | f72e171587708782db4a0f82e9a2c5b76d16a927 (diff) | |
parent | 3a0c0fe1c8b2242250735675b64114fadbfc0aee (diff) |
Merge pull request #18 from neverpanic/master
`System.Posix.Files.fileAccess` fails inside OS X sandbox
Diffstat (limited to 'System')
-rw-r--r-- | System/Posix/Files.hsc | 3 | ||||
-rw-r--r-- | System/Posix/Files/ByteString.hsc | 25 |
2 files changed, 15 insertions, 13 deletions
diff --git a/System/Posix/Files.hsc b/System/Posix/Files.hsc index 1822294..6aea6a9 100644 --- a/System/Posix/Files.hsc +++ b/System/Posix/Files.hsc @@ -154,7 +154,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 cb68668..ec58cb1 100644 --- a/System/Posix/Files/ByteString.hsc +++ b/System/Posix/Files/ByteString.hsc @@ -147,22 +147,23 @@ 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 || err == eROFS || err == eTXTBSY || + err == ePERM) + then return False + else throwErrnoPath "fileAccess" name -- | @getFileStatus path@ calls gets the @FileStatus@ information (user ID, @@ -278,7 +279,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" @@ -325,7 +326,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 |