System.Unix.Directory

Unixutils-1.54.1: A crude interface between Haskell and Unix-like operating systems

Safe Haskell | Safe
Language | Haskell98

System.Unix.Directory

Synopsis

- find :: FilePath -> IO [(FilePath, FileStatus)]
- removeRecursiveSafely :: FilePath -> IO ()
- unmountRecursiveSafely :: FilePath -> IO ()
- renameFileWithBackup :: FilePath -> FilePath -> IO ()
- withWorkingDirectory :: FilePath -> IO a -> IO a
- withTemporaryDirectory :: FilePath -> (FilePath -> IO a) -> IO a
- mkdtemp :: FilePath -> IO FilePath

# Documentation

find :: FilePath -> IO [(FilePath, FileStatus)] #

Traverse a directory and return a list of all the (path, fileStatus) pairs.

removeRecursiveSafely :: FilePath -> IO () #

Recursively remove a directory contents on a single file system. The adjective "Safely" refers to these features: 1. It will not follow symlinks 2. If it finds a directory that seems to be a mount point, it will attempt to unmount it up to five times. If it still seems to be a mount point it gives up 3. It doesn't use procmounts, which is ambiguous or wrong when you are inside a chroot.

unmountRecursiveSafely :: FilePath -> IO () #

Like removeRecursiveSafely but doesn't remove any files, just unmounts anything it finds mounted. Note that this can be much slower than Mount.umountBelow, use that instead.

renameFileWithBackup :: FilePath -> FilePath -> IO () #

Rename src to dst, and if dst already exists move it to dst~. If dst~ exists it is removed.

withWorkingDirectory :: FilePath -> IO a -> IO a #

temporarily change the working directory to |dir| while running |action|

withTemporaryDirectory :: FilePath -> (FilePath -> IO a) -> IO a #

create a temporary directory, run the action, remove the temporary directory the first argument is a template for the temporary directory name the directory will be created as a subdirectory of the directory returned by getTemporaryDirectory the temporary directory will be automatically removed afterwards. your working directory is not altered

mkdtemp :: FilePath -> IO FilePath #