import System.Posix.Types
import System.Time ( ClockTime(..) )
import System.IO
+import System.IO.Error
import Foreign
import Foreign.C
#ifdef __GLASGOW_HASKELL__
-import GHC.Posix
+import System.Posix.Internals
import GHC.IOBase ( IOException(..), IOErrorType(..), ioException )
#endif
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)
directory, or across different physical devices), but the constraints
must be documented.
+On Win32 platforms, @renameDirectory@ fails if the /new/ directory already
+exists.
+
The operation may fail with:
* 'HardwareFault'
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)
foreign import ccall unsafe "__hscore_path_max"
path_max :: Int
-foreign import ccall unsafe "__hscore_readdir"
- readdir :: Ptr CDir -> Ptr (Ptr CDirent) -> IO CInt
-
-foreign import ccall unsafe "__hscore_free_dirent"
- freeDirEnt :: Ptr CDirent -> IO ()
-
-foreign import ccall unsafe "__hscore_end_of_dir"
- end_of_dir :: CInt
-
-foreign import ccall unsafe "__hscore_d_name"
- d_name :: Ptr CDirent -> IO CString
-
foreign import ccall unsafe "__hscore_R_OK" r_OK :: CMode
foreign import ccall unsafe "__hscore_W_OK" w_OK :: CMode
foreign import ccall unsafe "__hscore_X_OK" x_OK :: CMode