diff options
Diffstat (limited to 'System/Posix/Files/ByteString.hsc')
-rw-r--r-- | System/Posix/Files/ByteString.hsc | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/System/Posix/Files/ByteString.hsc b/System/Posix/Files/ByteString.hsc index ec58cb1..0d19ae8 100644 --- a/System/Posix/Files/ByteString.hsc +++ b/System/Posix/Files/ByteString.hsc @@ -8,7 +8,7 @@ -- Module : System.Posix.Files.ByteString -- Copyright : (c) The University of Glasgow 2002 -- License : BSD-style (see the file libraries/base/LICENSE) --- +-- -- Maintainer : libraries@haskell.org -- Stability : provisional -- Portability : non-portable (requires POSIX) @@ -62,7 +62,7 @@ module System.Posix.Files.ByteString ( isDirectory, isSymbolicLink, isSocket, -- * Creation - createNamedPipe, + createNamedPipe, createDevice, -- * Hard links @@ -143,7 +143,7 @@ fileAccess name readOK writeOK execOK = access name flags -- -- Note: calls @access@. fileExist :: RawFilePath -> IO Bool -fileExist name = +fileExist name = withFilePath name $ \s -> do r <- c_access s (#const F_OK) if (r == 0) @@ -154,7 +154,7 @@ fileExist name = else throwErrnoPath "fileExist" name access :: RawFilePath -> CMode -> IO Bool -access name flags = +access name flags = withFilePath name $ \s -> do r <- c_access s (fromIntegral flags) if (r == 0) @@ -172,9 +172,9 @@ access name flags = -- Note: calls @stat@. getFileStatus :: RawFilePath -> IO FileStatus getFileStatus path = do - fp <- mallocForeignPtrBytes (#const sizeof(struct stat)) + fp <- mallocForeignPtrBytes (#const sizeof(struct stat)) withForeignPtr fp $ \p -> - withFilePath path $ \s -> + withFilePath path $ \s -> throwErrnoPathIfMinus1Retry_ "getFileStatus" path (c_stat s p) return (FileStatus fp) @@ -185,9 +185,9 @@ getFileStatus path = do -- Note: calls @lstat@. getSymbolicLinkStatus :: RawFilePath -> IO FileStatus getSymbolicLinkStatus path = do - fp <- mallocForeignPtrBytes (#const sizeof(struct stat)) + fp <- mallocForeignPtrBytes (#const sizeof(struct stat)) withForeignPtr fp $ \p -> - withFilePath path $ \s -> + withFilePath path $ \s -> throwErrnoPathIfMinus1_ "getSymbolicLinkStatus" path (c_lstat s p) return (FileStatus fp) @@ -203,7 +203,7 @@ foreign import ccall unsafe "__hsunix_lstat" -- Note: calls @mkfifo@. createNamedPipe :: RawFilePath -> FileMode -> IO () createNamedPipe name mode = do - withFilePath name $ \s -> + withFilePath name $ \s -> throwErrnoPathIfMinus1_ "createNamedPipe" name (c_mkfifo s mode) -- | @createDevice path mode dev@ creates either a regular or a special file @@ -219,7 +219,7 @@ createDevice path mode dev = withFilePath path $ \s -> throwErrnoPathIfMinus1_ "createDevice" path (c_mknod s mode dev) -foreign import ccall unsafe "__hsunix_mknod" +foreign import ccall unsafe "__hsunix_mknod" c_mknod :: CString -> CMode -> CDev -> IO CInt -- ----------------------------------------------------------------------------- @@ -278,7 +278,7 @@ readSymbolicLink :: RawFilePath -> IO RawFilePath readSymbolicLink file = allocaArray0 (#const PATH_MAX) $ \buf -> do withFilePath file $ \s -> do - len <- throwErrnoPathIfMinus1 "readSymbolicLink" file $ + len <- throwErrnoPathIfMinus1 "readSymbolicLink" file $ c_readlink s buf (#const PATH_MAX) peekFilePathLen (buf,fromIntegral len) @@ -419,7 +419,7 @@ touchSymbolicLink = -- -- Note: calls @truncate@. setFileSize :: RawFilePath -> FileOffset -> IO () -setFileSize file off = +setFileSize file off = withFilePath file $ \s -> throwErrnoPathIfMinus1_ "setFileSize" file (c_truncate s off) @@ -438,9 +438,9 @@ foreign import capi unsafe "HsUnix.h truncate" -- Note: calls @pathconf@. getPathVar :: RawFilePath -> PathVar -> IO Limit getPathVar name v = do - withFilePath name $ \ nameP -> - throwErrnoPathIfMinus1 "getPathVar" name $ + withFilePath name $ \ nameP -> + throwErrnoPathIfMinus1 "getPathVar" name $ c_pathconf nameP (pathVarConst v) -foreign import ccall unsafe "pathconf" +foreign import ccall unsafe "pathconf" c_pathconf :: CString -> CInt -> IO CLong |