hpath-io-0.10.1: High-level IO operations on files/directories

Copyright© 2016 Julian Ospald
MaintainerJulian Ospald <hasufell@posteo.de>
Safe HaskellNone




Provides error handling.



data RecursiveFailureHint Source #

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.

Exception identifiers

Path based functions

throwFileDoesExist :: Path b -> IO () Source #

Throws AlreadyExists IOError if file exists.

throwDirDoesExist :: Path b -> IO () Source #

Throws AlreadyExists IOError if directory exists.

throwSameFile :: Path b1 -> Path b2 -> IO () Source #

Uses isSameFile and throws SameFile if it returns True.

sameFile :: Path b1 -> Path b2 -> IO Bool Source #

Check if the files are the same by examining device and file id. This follows symbolic links.

throwDestinationInSource Source #


:: Path b1

source dir

-> Path b2

full destination, dirname dest must exist

-> IO () 

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.

Error handling functions

catchErrno Source #


:: [Errno]

errno to catch

-> IO a

action to try, which can raise an IOException

-> IO a

action to carry out in case of an IOException and if errno matches

-> IO a 

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.

rethrowErrnoAs Source #


:: Exception e 
=> [Errno]

errno to catch

-> e

rethrow as if errno matches

-> IO a

action to try

-> 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.

handleIOError :: (IOError -> IO a) -> IO a -> IO a Source #

Like catchIOError, with arguments swapped.

bracketeer Source #


:: IO a

computation to run first

-> (a -> IO b)

computation to run last, when no exception was raised

-> (a -> IO b)

computation to run last, when an exception was raised

-> (a -> IO c)

computation to run in-between

-> IO c 

Like bracket, but allows to have different clean-up actions depending on whether the in-between computation has raised an exception or not.

reactOnError Source #


:: IO a 
-> [(IOErrorType, IO a)]

reaction on IO errors

-> [(HPathIOException, IO a)]

reaction on HPathIOException

-> IO a