diff options
author | Herbert Valerio Riedel <hvr@gnu.org> | 2014-12-06 17:08:06 +0100 |
---|---|---|
committer | Herbert Valerio Riedel <hvr@gnu.org> | 2014-12-06 17:08:06 +0100 |
commit | 078666f4399f368e2f3dd82b5081dc1ad9b9fdc2 (patch) | |
tree | 247882ab50a9e32a659aa513751f9e16ec310207 /System/Posix/Directory/ByteString.hsc | |
parent | 558b0fb4eaa4aebc823022b3e1d560da3faad658 (diff) |
`M-x untabify` && `M-x delete-trailing-whitespace`
Diffstat (limited to 'System/Posix/Directory/ByteString.hsc')
-rw-r--r-- | System/Posix/Directory/ByteString.hsc | 54 |
1 files changed, 27 insertions, 27 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" |