-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Alternative to 'directory' package with ByteString based filepaths -- -- This provides a safer alternative to the directory package. -- FilePaths are ByteString based, so this package only works on POSIX -- systems. For a more high-level version of this with proper Path type, -- use 'hpath-io', which makes use of this package. @package hpath-directory @version 0.13.0 module System.Posix.Foreign newtype DirType DirType :: Int -> DirType data Flags Flags :: Int -> Flags UnsupportedFlag :: String -> Flags unFlags :: Flags -> Int -- | Returns True if posix-paths was compiled with support for the -- provided flag. (As of this writing, the only flag for which this check -- may be necessary is oCloexec; all other flags will always yield -- True.) isSupported :: Flags -> Bool -- | O_CLOEXEC is not supported on every POSIX platform. Use -- isSupported oCloexec to determine if support for -- O_CLOEXEC was compiled into your version of posix-paths. (If -- not, using oCloexec will throw an exception.) oCloexec :: Flags dtBlk :: DirType oAppend :: Flags dtChr :: DirType pathMax :: Int oAsync :: Flags dtDir :: DirType oCreat :: Flags dtFifo :: DirType unionFlags :: [Flags] -> CInt dtLnk :: DirType oDirectory :: Flags oExcl :: Flags dtReg :: DirType oNoctty :: Flags dtSock :: DirType oNofollow :: Flags dtUnknown :: DirType oNonblock :: Flags oRdonly :: Flags oWronly :: Flags oRdwr :: Flags oSync :: Flags oTrunc :: Flags instance GHC.Show.Show System.Posix.Foreign.Flags instance GHC.Classes.Eq System.Posix.Foreign.Flags instance GHC.Show.Show System.Posix.Foreign.DirType instance GHC.Classes.Eq System.Posix.Foreign.DirType -- | Provides an alternative for openFd which gives us more control -- on what status flags to pass to the low-level open(2) call, -- in contrast to the unix package. module System.Posix.FD -- | Open and optionally create this file. See Files for information -- on how to use the FileMode type. -- -- Note that passing Just x as the 4th argument triggers the -- oCreat status flag, which must be set when you pass in -- oExcl to the status flags. Also see the manpage for -- open(2). openFd :: RawFilePath -> OpenMode -> [Flags] -> Maybe FileMode -> IO Fd -- | Provides error handling. module System.Posix.RawFilePath.Directory.Errors -- | Additional generic IO exceptions that the posix functions do not -- provide. data HPathIOException SameFile :: ByteString -> ByteString -> HPathIOException DestinationInSource :: ByteString -> ByteString -> HPathIOException RecursiveFailure :: [(RecursiveFailureHint, IOException)] -> HPathIOException -- | A type for giving failure hints on recursive failure, which allows to -- programmatically make choices without examining the weakly typed I/O -- error attributes (like ioeGetFileName). -- -- The first argument to the data constructor is always the source and -- the second the destination. data RecursiveFailureHint ReadContentsFailed :: ByteString -> ByteString -> RecursiveFailureHint CreateDirFailed :: ByteString -> ByteString -> RecursiveFailureHint CopyFileFailed :: ByteString -> ByteString -> RecursiveFailureHint RecreateSymlinkFailed :: ByteString -> ByteString -> RecursiveFailureHint isSameFile :: HPathIOException -> Bool isDestinationInSource :: HPathIOException -> Bool isRecursiveFailure :: HPathIOException -> Bool isReadContentsFailed :: RecursiveFailureHint -> Bool isCreateDirFailed :: RecursiveFailureHint -> Bool isCopyFileFailed :: RecursiveFailureHint -> Bool isRecreateSymlinkFailed :: RecursiveFailureHint -> Bool -- | Throws AlreadyExists IOError if file exists. throwFileDoesExist :: RawFilePath -> IO () -- | Throws AlreadyExists IOError if directory exists. throwDirDoesExist :: RawFilePath -> IO () -- | Uses isSameFile and throws SameFile if it returns True. throwSameFile :: RawFilePath -> RawFilePath -> IO () -- | Check if the files are the same by examining device and file id. This -- follows symbolic links. sameFile :: RawFilePath -> RawFilePath -> IO Bool -- | Checks whether the destination directory is contained within the -- source directory by comparing the device+file ID of the source -- directory with all device+file IDs of the parent directories of the -- destination. throwDestinationInSource :: RawFilePath -> RawFilePath -> IO () -- | Carries out an action, then checks if there is an IOException and a -- specific errno. If so, then it carries out another action, otherwise -- it rethrows the error. catchErrno :: [Errno] -> IO a -> IO a -> IO a -- | Execute the given action and retrow IO exceptions as a new Exception -- that have the given errno. If errno does not match the exception is -- rethrown as is. rethrowErrnoAs :: Exception e => [Errno] -> e -> IO a -> IO a -- | Like catchIOError, with arguments swapped. handleIOError :: (IOError -> IO a) -> IO a -> IO a hideError :: IOErrorType -> IO () -> IO () -- | Like bracket, but allows to have different clean-up actions -- depending on whether the in-between computation has raised an -- exception or not. bracketeer :: IO a -> (a -> IO b) -> (a -> IO b) -> (a -> IO c) -> IO c reactOnError :: IO a -> [(IOErrorType, IO a)] -> [(HPathIOException, IO a)] -> IO a instance GHC.Show.Show System.Posix.RawFilePath.Directory.Errors.HPathIOException instance GHC.Classes.Eq System.Posix.RawFilePath.Directory.Errors.HPathIOException instance GHC.Show.Show System.Posix.RawFilePath.Directory.Errors.RecursiveFailureHint instance GHC.Classes.Eq System.Posix.RawFilePath.Directory.Errors.RecursiveFailureHint instance GHC.Exception.Type.Exception System.Posix.RawFilePath.Directory.Errors.HPathIOException -- | Traversal and read operations on directories. module System.Posix.RawFilePath.Directory.Traversals -- | Gets all directory contents (not recursively). getDirectoryContents :: RawFilePath -> IO [(DirType, RawFilePath)] -- | Like getDirectoryContents except for a file descriptor. -- -- To avoid complicated error checks, the file descriptor is -- always closed, even if fdOpendir fails. Usually, this -- only happens on successful fdOpendir and after the directory -- stream is closed. Also see the manpage of fdopendir(3) for -- more details. getDirectoryContents' :: Fd -> IO [(DirType, RawFilePath)] -- | Get all files from a directory and its subdirectories. -- -- Upon entering a directory, allDirectoryContents will get all -- entries strictly. However the returned list is lazy in that -- directories will only be accessed on demand. -- -- Follows symbolic links for the input dir. allDirectoryContents :: RawFilePath -> IO [RawFilePath] -- | Get all files from a directory and its subdirectories strictly. -- -- Follows symbolic links for the input dir. allDirectoryContents' :: RawFilePath -> IO [RawFilePath] -- | Recursively apply the action to the parent directory and all -- files/subdirectories. -- -- This function allows for memory-efficient traversals. -- -- Follows symbolic links for the input dir. traverseDirectory :: (s -> RawFilePath -> IO s) -> s -> RawFilePath -> IO s readDirEnt :: DirStream -> IO (DirType, RawFilePath) packDirStream :: Ptr CDir -> DirStream unpackDirStream :: DirStream -> Ptr CDir -- | Binding to fdopendir(3). fdOpendir :: Fd -> IO DirStream -- | return the canonicalized absolute pathname -- -- like canonicalizePath, but uses realpath(3) realpath :: RawFilePath -> IO RawFilePath -- | This module provides IO related file operations like copy, delete, -- move and so on, similar to the directory package. -- -- Some of these operations are due to their nature not atomic, -- which means they may do multiple syscalls which form one context. Some -- of them also have to examine the filetypes explicitly before the -- syscalls, so a reasonable decision can be made. That means the result -- is undefined if another process changes that context while the -- non-atomic operation is still happening. However, where possible, as -- few syscalls as possible are used and the underlying exception -- handling is kept. -- -- Note: BlockDevice, CharacterDevice, NamedPipe and -- Socket are ignored by some of the more high-level functions -- (like easyCopy). For other functions (like copyFile), -- the behavior on these file types is unreliable/unsafe. Check the -- documentation of those functions for details. -- -- Import as: > import System.Posix.RawFilePath.Directory module System.Posix.RawFilePath.Directory data FileType Directory :: FileType RegularFile :: FileType SymbolicLink :: FileType BlockDevice :: FileType CharacterDevice :: FileType NamedPipe :: FileType Socket :: FileType -- | The error mode for recursive operations. -- -- On FailEarly the whole operation fails immediately if any of -- the recursive sub-operations fail, which is sort of the default for IO -- operations. -- -- On CollectFailures skips errors in the recursion and keeps on -- recursing. However all errors are collected in the -- RecursiveFailure error type, which is raised finally if there -- was any error. Also note that RecursiveFailure does not give -- any guarantees on the ordering of the collected exceptions. data RecursiveErrorMode FailEarly :: RecursiveErrorMode CollectFailures :: RecursiveErrorMode -- | The mode for copy and file moves. Overwrite mode is usually not very -- well defined, but is a convenience shortcut. data CopyMode -- | fail if any target exists Strict :: CopyMode -- | overwrite targets Overwrite :: CopyMode -- | Copies the contents of a directory recursively to the given -- destination, while preserving permissions. Does not follow symbolic -- links. This behaves more or less like the following, without -- descending into the destination if it already exists: -- --
-- cp -a /source/dir /destination/somedir ---- -- For directory contents, this will ignore any file type that is not -- RegularFile, SymbolicLink or Directory. -- -- For Overwrite copy mode this does not prune destination -- directory contents, so the destination might contain more files than -- the source after the operation has completed. Permissions of existing -- directories are fixed. -- -- Safety/reliability concerns: -- --
-- mkdir -p /some/dir ---- -- Safety/reliability concerns: -- --