import System.Posix.Types
import System.Time ( ClockTime(..) )
import System.IO
+import System.IO.Error
import Foreign
import Foreign.C
removeDirectory :: FilePath -> IO ()
removeDirectory path = do
+ modifyIOError (`ioeSetFileName` path) $
withCString path $ \s ->
throwErrnoIfMinus1Retry_ "removeDirectory" (c_rmdir s)
removeFile :: FilePath -> IO ()
removeFile path = do
+ modifyIOError (`ioeSetFileName` path) $
withCString path $ \s ->
throwErrnoIfMinus1Retry_ "removeFile" (c_unlink s)
getDirectoryContents :: FilePath -> IO [FilePath]
getDirectoryContents path = do
+ modifyIOError (`ioeSetFileName` path) $
alloca $ \ ptr_dEnt ->
bracket
(withCString path $ \s ->
setCurrentDirectory :: FilePath -> IO ()
setCurrentDirectory path = do
+ modifyIOError (`ioeSetFileName` path) $
withCString path $ \s ->
throwErrnoIfMinus1Retry_ "setCurrentDirectory" (c_chdir s)
-- ToDo: add path to error
withFileStatus :: FilePath -> (Ptr CStat -> IO a) -> IO a
withFileStatus name f = do
+ modifyIOError (`ioeSetFileName` name) $
allocaBytes sizeof_stat $ \p ->
withCString (fileNameEndClean name) $ \s -> do
throwErrnoIfMinus1Retry_ "withFileStatus" (c_stat s p)
withFileOrSymlinkStatus :: FilePath -> (Ptr CStat -> IO a) -> IO a
withFileOrSymlinkStatus name f = do
+ modifyIOError (`ioeSetFileName` name) $
allocaBytes sizeof_stat $ \p ->
withCString name $ \s -> do
throwErrnoIfMinus1Retry_ "withFileOrSymlinkStatus" (lstat s p)