diff options
Diffstat (limited to 'System/Posix/Directory')
-rw-r--r-- | System/Posix/Directory/ByteString.hsc | 54 | ||||
-rw-r--r-- | System/Posix/Directory/Common.hsc | 4 |
2 files changed, 29 insertions, 29 deletions
diff --git a/System/Posix/Directory/ByteString.hsc b/System/Posix/Directory/ByteString.hsc index 28edd35..232427c 100644 --- a/System/Posix/Directory/ByteString.hsc +++ b/System/Posix/Directory/ByteString.hsc @@ -8,7 +8,7 @@ -- Module : System.Posix.Directory.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) @@ -27,7 +27,7 @@ module System.Posix.Directory.ByteString ( DirStream, openDirStream, readDirStream, - rewindDirStream, + rewindDirStream, closeDirStream, DirStreamOffset, #ifdef HAVE_TELLDIR @@ -58,8 +58,8 @@ import System.Posix.ByteString.FilePath -- @mode@. createDirectory :: RawFilePath -> FileMode -> IO () createDirectory name mode = - withFilePath name $ \s -> - throwErrnoPathIfMinus1Retry_ "createDirectory" name (c_mkdir s mode) + withFilePath name $ \s -> + throwErrnoPathIfMinus1Retry_ "createDirectory" name (c_mkdir s mode) -- POSIX doesn't allow mkdir() to return EINTR, but it does on -- OS X (#5184), so we need the Retry variant here. @@ -89,19 +89,19 @@ readDirStream (DirStream dirp) = resetErrno r <- c_readdir dirp ptr_dEnt if (r == 0) - then do dEnt <- peek ptr_dEnt - if (dEnt == nullPtr) + then do dEnt <- peek ptr_dEnt + if (dEnt == nullPtr) then return BC.empty - else do - entry <- (d_name dEnt >>= peekFilePath) - c_freeDirEnt dEnt - return entry - else do errno <- getErrno - if (errno == eINTR) then loop ptr_dEnt else do - let (Errno eo) = errno - if (eo == 0) + else do + entry <- (d_name dEnt >>= peekFilePath) + c_freeDirEnt dEnt + return entry + else do errno <- getErrno + if (errno == eINTR) then loop ptr_dEnt else do + let (Errno eo) = errno + if (eo == 0) then return BC.empty - else throwErrno "readDirStream" + else throwErrno "readDirStream" -- traversing directories foreign import ccall unsafe "__hscore_readdir" @@ -121,17 +121,17 @@ getWorkingDirectory = do p <- mallocBytes long_path_size go p long_path_size where go p bytes = do - p' <- c_getcwd p (fromIntegral bytes) - if p' /= nullPtr - then do s <- peekFilePath p' - free p' - return s - else do errno <- getErrno - if errno == eRANGE - then do let bytes' = bytes * 2 - p'' <- reallocBytes p bytes' - go p'' bytes' - else throwErrno "getCurrentDirectory" + p' <- c_getcwd p (fromIntegral bytes) + if p' /= nullPtr + then do s <- peekFilePath p' + free p' + return s + else do errno <- getErrno + if errno == eRANGE + then do let bytes' = bytes * 2 + p'' <- reallocBytes p bytes' + go p'' bytes' + else throwErrno "getCurrentDirectory" foreign import ccall unsafe "getcwd" c_getcwd :: Ptr CChar -> CSize -> IO (Ptr CChar) @@ -144,7 +144,7 @@ foreign import ccall unsafe "__hsunix_long_path_size" changeWorkingDirectory :: RawFilePath -> IO () changeWorkingDirectory path = modifyIOError (`ioeSetFileName` (BC.unpack path)) $ - withFilePath path $ \s -> + withFilePath path $ \s -> throwErrnoIfMinus1Retry_ "changeWorkingDirectory" (c_chdir s) foreign import ccall unsafe "chdir" diff --git a/System/Posix/Directory/Common.hsc b/System/Posix/Directory/Common.hsc index 7cc61af..ea43c5c 100644 --- a/System/Posix/Directory/Common.hsc +++ b/System/Posix/Directory/Common.hsc @@ -7,7 +7,7 @@ -- Module : System.Posix.Directory.Common -- 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) @@ -79,7 +79,7 @@ foreign import ccall unsafe "telldir" #endif changeWorkingDirectoryFd :: Fd -> IO () -changeWorkingDirectoryFd (Fd fd) = +changeWorkingDirectoryFd (Fd fd) = throwErrnoIfMinus1Retry_ "changeWorkingDirectoryFd" (c_fchdir fd) foreign import ccall unsafe "fchdir" |