2016-06-01 12:52:48 +00:00
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
< html >
< head >
<!-- Generated by HsColour, http://code.haskell.org/~malcolm/hscolour/ -->
< title > src/HPath/IO/Errors.hs< / title >
< link type = 'text/css' rel = 'stylesheet' href = 'hscolour.css' / >
< / head >
< body >
< pre > < a name = "line-1" > < / a > < span class = 'hs-comment' > -- |< / span >
< a name = "line-2" > < / a > < span class = 'hs-comment' > -- Module : HPath.IO.Errors< / span >
< a name = "line-3" > < / a > < span class = 'hs-comment' > -- Copyright : © 2016 Julian Ospald< / span >
2016-06-03 22:27:22 +00:00
< a name = "line-4" > < / a > < span class = 'hs-comment' > -- License : BSD3< / span >
2016-06-01 12:52:48 +00:00
< a name = "line-5" > < / a > < span class = 'hs-comment' > --< / span >
< a name = "line-6" > < / a > < span class = 'hs-comment' > -- Maintainer : Julian Ospald < hasufell@posteo.de> < / span >
< a name = "line-7" > < / a > < span class = 'hs-comment' > -- Stability : experimental< / span >
< a name = "line-8" > < / a > < span class = 'hs-comment' > -- Portability : portable< / span >
< a name = "line-9" > < / a > < span class = 'hs-comment' > --< / span >
< a name = "line-10" > < / a > < span class = 'hs-comment' > -- Provides error handling.< / span >
< a name = "line-11" > < / a >
< a name = "line-12" > < / a > < span class = 'hs-comment' > {-# LANGUAGE DeriveDataTypeable #-}< / span >
< a name = "line-13" > < / a > < span class = 'hs-comment' > {-# LANGUAGE ScopedTypeVariables #-}< / span >
< a name = "line-14" > < / a >
< a name = "line-15" > < / a > < span class = 'hs-keyword' > module< / span > < span class = 'hs-conid' > HPath< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-conid' > IO< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-conid' > Errors< / span >
< a name = "line-16" > < / a > < span class = 'hs-layout' > (< / span >
< a name = "line-17" > < / a > < span class = 'hs-comment' > -- * Types< / span >
< a name = "line-18" > < / a > < span class = 'hs-conid' > HPathIOException< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-keyglyph' > ..< / span > < span class = 'hs-layout' > )< / span >
< a name = "line-19" > < / a >
< a name = "line-20" > < / a > < span class = 'hs-comment' > -- * Exception identifiers< / span >
< a name = "line-21" > < / a > < span class = 'hs-layout' > ,< / span > < span class = 'hs-varid' > isFileDoesNotExist< / span >
< a name = "line-22" > < / a > < span class = 'hs-layout' > ,< / span > < span class = 'hs-varid' > isDirDoesNotExist< / span >
< a name = "line-23" > < / a > < span class = 'hs-layout' > ,< / span > < span class = 'hs-varid' > isSameFile< / span >
< a name = "line-24" > < / a > < span class = 'hs-layout' > ,< / span > < span class = 'hs-varid' > isDestinationInSource< / span >
< a name = "line-25" > < / a > < span class = 'hs-layout' > ,< / span > < span class = 'hs-varid' > isFileDoesExist< / span >
< a name = "line-26" > < / a > < span class = 'hs-layout' > ,< / span > < span class = 'hs-varid' > isDirDoesExist< / span >
< a name = "line-27" > < / a > < span class = 'hs-layout' > ,< / span > < span class = 'hs-varid' > isInvalidOperation< / span >
< a name = "line-28" > < / a > < span class = 'hs-layout' > ,< / span > < span class = 'hs-varid' > isCan'tOpenDirectory< / span >
< a name = "line-29" > < / a > < span class = 'hs-layout' > ,< / span > < span class = 'hs-varid' > isCopyFailed< / span >
< a name = "line-30" > < / a >
< a name = "line-31" > < / a > < span class = 'hs-comment' > -- * Path based functions< / span >
< a name = "line-32" > < / a > < span class = 'hs-layout' > ,< / span > < span class = 'hs-varid' > throwFileDoesExist< / span >
< a name = "line-33" > < / a > < span class = 'hs-layout' > ,< / span > < span class = 'hs-varid' > throwDirDoesExist< / span >
< a name = "line-34" > < / a > < span class = 'hs-layout' > ,< / span > < span class = 'hs-varid' > throwFileDoesNotExist< / span >
< a name = "line-35" > < / a > < span class = 'hs-layout' > ,< / span > < span class = 'hs-varid' > throwDirDoesNotExist< / span >
< a name = "line-36" > < / a > < span class = 'hs-layout' > ,< / span > < span class = 'hs-varid' > throwSameFile< / span >
< a name = "line-37" > < / a > < span class = 'hs-layout' > ,< / span > < span class = 'hs-varid' > sameFile< / span >
< a name = "line-38" > < / a > < span class = 'hs-layout' > ,< / span > < span class = 'hs-varid' > throwDestinationInSource< / span >
< a name = "line-39" > < / a > < span class = 'hs-layout' > ,< / span > < span class = 'hs-varid' > doesFileExist< / span >
< a name = "line-40" > < / a > < span class = 'hs-layout' > ,< / span > < span class = 'hs-varid' > doesDirectoryExist< / span >
< a name = "line-41" > < / a > < span class = 'hs-layout' > ,< / span > < span class = 'hs-varid' > isWritable< / span >
< a name = "line-42" > < / a > < span class = 'hs-layout' > ,< / span > < span class = 'hs-varid' > canOpenDirectory< / span >
< a name = "line-43" > < / a > < span class = 'hs-layout' > ,< / span > < span class = 'hs-varid' > throwCantOpenDirectory< / span >
< a name = "line-44" > < / a >
< a name = "line-45" > < / a > < span class = 'hs-comment' > -- * Error handling functions< / span >
< a name = "line-46" > < / a > < span class = 'hs-layout' > ,< / span > < span class = 'hs-varid' > catchErrno< / span >
< a name = "line-47" > < / a > < span class = 'hs-layout' > ,< / span > < span class = 'hs-varid' > rethrowErrnoAs< / span >
< a name = "line-48" > < / a > < span class = 'hs-layout' > ,< / span > < span class = 'hs-varid' > handleIOError< / span >
< a name = "line-49" > < / a > < span class = 'hs-layout' > ,< / span > < span class = 'hs-varid' > bracketeer< / span >
< a name = "line-50" > < / a > < span class = 'hs-layout' > ,< / span > < span class = 'hs-varid' > reactOnError< / span >
< a name = "line-51" > < / a > < span class = 'hs-layout' > )< / span >
< a name = "line-52" > < / a > < span class = 'hs-keyword' > where< / span >
< a name = "line-53" > < / a >
< a name = "line-54" > < / a >
< a name = "line-55" > < / a > < span class = 'hs-keyword' > import< / span > < span class = 'hs-conid' > Control< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-conid' > Applicative< / span >
< a name = "line-56" > < / a > < span class = 'hs-layout' > (< / span >
< a name = "line-57" > < / a > < span class = 'hs-layout' > (< / span > < span class = 'hs-varop' > < $> < / span > < span class = 'hs-layout' > )< / span >
< a name = "line-58" > < / a > < span class = 'hs-layout' > )< / span >
< a name = "line-59" > < / a > < span class = 'hs-keyword' > import< / span > < span class = 'hs-conid' > Control< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-conid' > Exception< / span >
< a name = "line-60" > < / a > < span class = 'hs-keyword' > import< / span > < span class = 'hs-conid' > Control< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-conid' > Monad< / span >
< a name = "line-61" > < / a > < span class = 'hs-layout' > (< / span >
< a name = "line-62" > < / a > < span class = 'hs-varid' > forM< / span >
< a name = "line-63" > < / a > < span class = 'hs-layout' > ,< / span > < span class = 'hs-varid' > when< / span >
< a name = "line-64" > < / a > < span class = 'hs-layout' > )< / span >
< a name = "line-65" > < / a > < span class = 'hs-keyword' > import< / span > < span class = 'hs-conid' > Data< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-conid' > ByteString< / span >
< a name = "line-66" > < / a > < span class = 'hs-layout' > (< / span >
< a name = "line-67" > < / a > < span class = 'hs-conid' > ByteString< / span >
< a name = "line-68" > < / a > < span class = 'hs-layout' > )< / span >
< a name = "line-69" > < / a > < span class = 'hs-keyword' > import< / span > < span class = 'hs-conid' > Data< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-conid' > ByteString< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-conid' > UTF8< / span >
< a name = "line-70" > < / a > < span class = 'hs-layout' > (< / span >
< a name = "line-71" > < / a > < span class = 'hs-varid' > toString< / span >
< a name = "line-72" > < / a > < span class = 'hs-layout' > )< / span >
< a name = "line-73" > < / a > < span class = 'hs-keyword' > import< / span > < span class = 'hs-conid' > Data< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-conid' > Data< / span >
< a name = "line-74" > < / a > < span class = 'hs-layout' > (< / span >
< a name = "line-75" > < / a > < span class = 'hs-conid' > Data< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-keyglyph' > ..< / span > < span class = 'hs-layout' > )< / span >
< a name = "line-76" > < / a > < span class = 'hs-layout' > )< / span >
< a name = "line-77" > < / a > < span class = 'hs-keyword' > import< / span > < span class = 'hs-conid' > Data< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-conid' > Typeable< / span >
< a name = "line-78" > < / a > < span class = 'hs-keyword' > import< / span > < span class = 'hs-conid' > Foreign< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-conid' > C< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-conid' > Error< / span >
< a name = "line-79" > < / a > < span class = 'hs-layout' > (< / span >
< a name = "line-80" > < / a > < span class = 'hs-varid' > getErrno< / span >
< a name = "line-81" > < / a > < span class = 'hs-layout' > ,< / span > < span class = 'hs-conid' > Errno< / span >
< a name = "line-82" > < / a > < span class = 'hs-layout' > )< / span >
< a name = "line-83" > < / a > < span class = 'hs-keyword' > import< / span > < span class = 'hs-conid' > GHC< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-conid' > IO< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-conid' > Exception< / span >
< a name = "line-84" > < / a > < span class = 'hs-layout' > (< / span >
< a name = "line-85" > < / a > < span class = 'hs-conid' > IOErrorType< / span >
< a name = "line-86" > < / a > < span class = 'hs-layout' > )< / span >
< a name = "line-87" > < / a > < span class = 'hs-keyword' > import< / span > < span class = 'hs-conid' > HPath< / span >
< a name = "line-88" > < / a > < span class = 'hs-keyword' > import< / span > < span class = 'hs-comment' > {-# SOURCE #-}< / span > < span class = 'hs-conid' > HPath< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-conid' > IO< / span >
< a name = "line-89" > < / a > < span class = 'hs-layout' > (< / span >
< a name = "line-90" > < / a > < span class = 'hs-varid' > canonicalizePath< / span >
< a name = "line-91" > < / a > < span class = 'hs-layout' > )< / span >
< a name = "line-92" > < / a > < span class = 'hs-keyword' > import< / span > < span class = 'hs-conid' > HPath< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-conid' > IO< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-conid' > Utils< / span >
< a name = "line-93" > < / a > < span class = 'hs-keyword' > import< / span > < span class = 'hs-conid' > System< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-conid' > IO< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-conid' > Error< / span >
< a name = "line-94" > < / a > < span class = 'hs-layout' > (< / span >
< a name = "line-95" > < / a > < span class = 'hs-varid' > catchIOError< / span >
< a name = "line-96" > < / a > < span class = 'hs-layout' > ,< / span > < span class = 'hs-varid' > ioeGetErrorType< / span >
< a name = "line-97" > < / a > < span class = 'hs-layout' > )< / span >
< a name = "line-98" > < / a >
< a name = "line-99" > < / a > < span class = 'hs-keyword' > import< / span > < span class = 'hs-keyword' > qualified< / span > < span class = 'hs-conid' > System< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-conid' > Posix< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-conid' > Directory< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-conid' > ByteString< / span > < span class = 'hs-keyword' > as< / span > < span class = 'hs-conid' > PFD< / span >
< a name = "line-100" > < / a > < span class = 'hs-keyword' > import< / span > < span class = 'hs-conid' > System< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-conid' > Posix< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-conid' > Files< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-conid' > ByteString< / span >
< a name = "line-101" > < / a > < span class = 'hs-layout' > (< / span >
< a name = "line-102" > < / a > < span class = 'hs-varid' > fileAccess< / span >
< a name = "line-103" > < / a > < span class = 'hs-layout' > ,< / span > < span class = 'hs-varid' > getFileStatus< / span >
< a name = "line-104" > < / a > < span class = 'hs-layout' > )< / span >
< a name = "line-105" > < / a > < span class = 'hs-keyword' > import< / span > < span class = 'hs-keyword' > qualified< / span > < span class = 'hs-conid' > System< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-conid' > Posix< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-conid' > Files< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-conid' > ByteString< / span > < span class = 'hs-keyword' > as< / span > < span class = 'hs-conid' > PF< / span >
< a name = "line-106" > < / a >
< a name = "line-107" > < / a >
< a name = "line-108" > < / a > < a name = "HPathIOException" > < / a > < span class = 'hs-keyword' > data< / span > < span class = 'hs-conid' > HPathIOException< / span > < span class = 'hs-keyglyph' > =< / span > < span class = 'hs-conid' > FileDoesNotExist< / span > < span class = 'hs-conid' > ByteString< / span >
< a name = "line-109" > < / a > < span class = 'hs-keyglyph' > |< / span > < span class = 'hs-conid' > DirDoesNotExist< / span > < span class = 'hs-conid' > ByteString< / span >
< a name = "line-110" > < / a > < span class = 'hs-keyglyph' > |< / span > < span class = 'hs-conid' > SameFile< / span > < span class = 'hs-conid' > ByteString< / span > < span class = 'hs-conid' > ByteString< / span >
< a name = "line-111" > < / a > < span class = 'hs-keyglyph' > |< / span > < span class = 'hs-conid' > DestinationInSource< / span > < span class = 'hs-conid' > ByteString< / span > < span class = 'hs-conid' > ByteString< / span >
< a name = "line-112" > < / a > < span class = 'hs-keyglyph' > |< / span > < span class = 'hs-conid' > FileDoesExist< / span > < span class = 'hs-conid' > ByteString< / span >
< a name = "line-113" > < / a > < span class = 'hs-keyglyph' > |< / span > < span class = 'hs-conid' > DirDoesExist< / span > < span class = 'hs-conid' > ByteString< / span >
< a name = "line-114" > < / a > < span class = 'hs-keyglyph' > |< / span > < span class = 'hs-conid' > InvalidOperation< / span > < span class = 'hs-conid' > String< / span >
< a name = "line-115" > < / a > < span class = 'hs-keyglyph' > |< / span > < span class = 'hs-conid' > Can'tOpenDirectory< / span > < span class = 'hs-conid' > ByteString< / span >
< a name = "line-116" > < / a > < span class = 'hs-keyglyph' > |< / span > < span class = 'hs-conid' > CopyFailed< / span > < span class = 'hs-conid' > String< / span >
< a name = "line-117" > < / a > < span class = 'hs-keyword' > deriving< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-conid' > Typeable< / span > < span class = 'hs-layout' > ,< / span > < span class = 'hs-conid' > Eq< / span > < span class = 'hs-layout' > ,< / span > < span class = 'hs-conid' > Data< / span > < span class = 'hs-layout' > )< / span >
< a name = "line-118" > < / a >
< a name = "line-119" > < / a >
< a name = "line-120" > < / a > < a name = "instance%20Show%20HPathIOException" > < / a > < span class = 'hs-keyword' > instance< / span > < span class = 'hs-conid' > Show< / span > < span class = 'hs-conid' > HPathIOException< / span > < span class = 'hs-keyword' > where< / span >
< a name = "line-121" > < / a > < span class = 'hs-varid' > show< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-conid' > FileDoesNotExist< / span > < span class = 'hs-varid' > fp< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-keyglyph' > =< / span > < span class = 'hs-str' > "File does not exist:"< / span > < span class = 'hs-varop' > ++< / span > < span class = 'hs-varid' > toString< / span > < span class = 'hs-varid' > fp< / span >
< a name = "line-122" > < / a > < span class = 'hs-varid' > show< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-conid' > DirDoesNotExist< / span > < span class = 'hs-varid' > fp< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-keyglyph' > =< / span > < span class = 'hs-str' > "Directory does not exist: "< / span >
< a name = "line-123" > < / a > < span class = 'hs-varop' > ++< / span > < span class = 'hs-varid' > toString< / span > < span class = 'hs-varid' > fp< / span >
< a name = "line-124" > < / a > < span class = 'hs-varid' > show< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-conid' > SameFile< / span > < span class = 'hs-varid' > fp1< / span > < span class = 'hs-varid' > fp2< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-keyglyph' > =< / span > < span class = 'hs-varid' > toString< / span > < span class = 'hs-varid' > fp1< / span >
< a name = "line-125" > < / a > < span class = 'hs-varop' > ++< / span > < span class = 'hs-str' > " and "< / span > < span class = 'hs-varop' > ++< / span > < span class = 'hs-varid' > toString< / span > < span class = 'hs-varid' > fp2< / span >
< a name = "line-126" > < / a > < span class = 'hs-varop' > ++< / span > < span class = 'hs-str' > " are the same file!"< / span >
< a name = "line-127" > < / a > < span class = 'hs-varid' > show< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-conid' > DestinationInSource< / span > < span class = 'hs-varid' > fp1< / span > < span class = 'hs-varid' > fp2< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-keyglyph' > =< / span > < span class = 'hs-varid' > toString< / span > < span class = 'hs-varid' > fp1< / span >
< a name = "line-128" > < / a > < span class = 'hs-varop' > ++< / span > < span class = 'hs-str' > " is contained in "< / span >
< a name = "line-129" > < / a > < span class = 'hs-varop' > ++< / span > < span class = 'hs-varid' > toString< / span > < span class = 'hs-varid' > fp2< / span >
< a name = "line-130" > < / a > < span class = 'hs-varid' > show< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-conid' > FileDoesExist< / span > < span class = 'hs-varid' > fp< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-keyglyph' > =< / span > < span class = 'hs-str' > "File does exist: "< / span > < span class = 'hs-varop' > ++< / span > < span class = 'hs-varid' > toString< / span > < span class = 'hs-varid' > fp< / span >
< a name = "line-131" > < / a > < span class = 'hs-varid' > show< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-conid' > DirDoesExist< / span > < span class = 'hs-varid' > fp< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-keyglyph' > =< / span > < span class = 'hs-str' > "Directory does exist: "< / span > < span class = 'hs-varop' > ++< / span > < span class = 'hs-varid' > toString< / span > < span class = 'hs-varid' > fp< / span >
< a name = "line-132" > < / a > < span class = 'hs-varid' > show< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-conid' > InvalidOperation< / span > < span class = 'hs-varid' > str< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-keyglyph' > =< / span > < span class = 'hs-str' > "Invalid operation: "< / span > < span class = 'hs-varop' > ++< / span > < span class = 'hs-varid' > str< / span >
< a name = "line-133" > < / a > < span class = 'hs-varid' > show< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-conid' > Can'tOpenDirectory< / span > < span class = 'hs-varid' > fp< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-keyglyph' > =< / span > < span class = 'hs-str' > "Can't open directory: "< / span >
< a name = "line-134" > < / a > < span class = 'hs-varop' > ++< / span > < span class = 'hs-varid' > toString< / span > < span class = 'hs-varid' > fp< / span >
< a name = "line-135" > < / a > < span class = 'hs-varid' > show< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-conid' > CopyFailed< / span > < span class = 'hs-varid' > str< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-keyglyph' > =< / span > < span class = 'hs-str' > "Copying failed: "< / span > < span class = 'hs-varop' > ++< / span > < span class = 'hs-varid' > str< / span >
< a name = "line-136" > < / a >
< a name = "line-137" > < / a >
< a name = "line-138" > < / a >
2016-06-01 17:00:53 +00:00
< a name = "line-139" > < / a > < a name = "instance%20%5bErrno%5d%20--%20%5e%20errno%20to%20catch%20-%3e%20e%20--%20%5e%20rethrow%20as%20if%20errno%20matches%20-%3e%20IO%20a%20--%20%5e%20action%20to%20try%20-%3e%20IO%20a%20rethrowErrnoAs%20en%20fmex%20action%20=%20catchErrno%20en%20action%20(throwIO%20fmex)%20--%20%7cLike%20%60catchIOError%60,%20with%20arguments%20swapped.%20handleIOError%20::%20(IOError%20-%3e%20IO%20a)%20-%3e%20IO%20a%20-%3e%20IO%20a%20handleIOError%20=%20flip%20catchIOError%20--%20%7cLike%20%60bracket%60,%20but%20allows%20to%20have%20different%20clean-up%20--%20actions%20depending%20on%20whether%20the%20in-between%20computation%20--%20has%20raised%20an%20exception%20or%20not.%20bracketeer%20::%20IO%20a%20--%20%5e%20computation%20to%20run%20first%20-%3e%20(a%20-%3e%20IO%20b)%20--%20%5e%20computation%20to%20run%20last,%20when%20--%20no%20exception%20was%20raised%20-%3e%20(a%20-%3e%20IO%20b)%20--%20%5e%20computation%20to%20run%20last,%20--%20when%20an%20exception%20was%20raised%20-%3e%20(a%20-%3e%20IO%20c)%20--%20%5e%20computation%20to%20run%20in-between%20-%3e%20IO%20c%20bracketeer%20before%20after%20afterEx%20thing%20=%20mask%20$%20%5crestore%20-%3e%20do%20a%20%3c-%20before%20r%20%3c-%20restore%20(thing%20a)%20%60onException%60%20afterEx%20a%20_%20%3c-%20after%20a%20return%20r%20reactOnError%20::%20IO%20a%20-%3e%20%5b(IOErrorType,%20IO%20a)%5d%20--%20%5e%20reaction%20on%20IO%20errors%20-%3e%20%5b(HPathIOException,%20IO%20a)%5d%20--%20%5e%20reaction%20on%20HPathIOException%20-%3e%20IO%20a%20reactOnError%20a%20ios%20fmios%20=%20a%20%60catches%60%20%5biohandler,%20fmiohandler%5d" > < / a > < span class = 'hs-keyword' > instance< / span > < span class = 'hs-conid' > Exception< / span > < span class = 'hs-conid' > HPathIOException< / span >
2016-06-01 12:52:48 +00:00
< a name = "line-140" > < / a >
< a name = "line-141" > < / a >
< a name = "line-142" > < / a >
< a name = "line-143" > < / a >
< a name = "line-144" > < / a >
< a name = "line-145" > < / a > < span class = 'hs-comment' > -----------------------------< / span >
< a name = "line-146" > < / a > < span class = 'hs-comment' > --[ Exception identifiers ]--< / span >
< a name = "line-147" > < / a > < span class = 'hs-comment' > -----------------------------< / span >
< a name = "line-148" > < / a >
< a name = "line-149" > < / a > < a name = "isFileDoesNotExist" > < / a > < span class = 'hs-definition' > isFileDoesNotExist< / span > < span class = 'hs-layout' > ,< / span > < span class = 'hs-varid' > isDirDoesNotExist< / span > < span class = 'hs-layout' > ,< / span > < span class = 'hs-varid' > isSameFile< / span > < span class = 'hs-layout' > ,< / span > < span class = 'hs-varid' > isDestinationInSource< / span > < span class = 'hs-layout' > ,< / span > < span class = 'hs-varid' > isFileDoesExist< / span > < span class = 'hs-layout' > ,< / span > < span class = 'hs-varid' > isDirDoesExist< / span > < span class = 'hs-layout' > ,< / span > < span class = 'hs-varid' > isInvalidOperation< / span > < span class = 'hs-layout' > ,< / span > < span class = 'hs-varid' > isCan'tOpenDirectory< / span > < span class = 'hs-layout' > ,< / span > < span class = 'hs-varid' > isCopyFailed< / span > < span class = 'hs-keyglyph' > ::< / span > < span class = 'hs-conid' > HPathIOException< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-conid' > Bool< / span >
< a name = "line-150" > < / a > < span class = 'hs-definition' > isFileDoesNotExist< / span > < span class = 'hs-varid' > ex< / span > < span class = 'hs-keyglyph' > =< / span > < span class = 'hs-varid' > toConstr< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-varid' > ex< / span > < span class = 'hs-keyglyph' > ::< / span > < span class = 'hs-conid' > HPathIOException< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-varop' > ==< / span > < span class = 'hs-varid' > toConstr< / span > < span class = 'hs-conid' > FileDoesNotExist< / span > < span class = 'hs-layout' > {< / span > < span class = 'hs-layout' > }< / span >
< a name = "line-151" > < / a > < a name = "isDirDoesNotExist" > < / a > < span class = 'hs-definition' > isDirDoesNotExist< / span > < span class = 'hs-varid' > ex< / span > < span class = 'hs-keyglyph' > =< / span > < span class = 'hs-varid' > toConstr< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-varid' > ex< / span > < span class = 'hs-keyglyph' > ::< / span > < span class = 'hs-conid' > HPathIOException< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-varop' > ==< / span > < span class = 'hs-varid' > toConstr< / span > < span class = 'hs-conid' > DirDoesNotExist< / span > < span class = 'hs-layout' > {< / span > < span class = 'hs-layout' > }< / span >
< a name = "line-152" > < / a > < a name = "isSameFile" > < / a > < span class = 'hs-definition' > isSameFile< / span > < span class = 'hs-varid' > ex< / span > < span class = 'hs-keyglyph' > =< / span > < span class = 'hs-varid' > toConstr< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-varid' > ex< / span > < span class = 'hs-keyglyph' > ::< / span > < span class = 'hs-conid' > HPathIOException< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-varop' > ==< / span > < span class = 'hs-varid' > toConstr< / span > < span class = 'hs-conid' > SameFile< / span > < span class = 'hs-layout' > {< / span > < span class = 'hs-layout' > }< / span >
< a name = "line-153" > < / a > < a name = "isDestinationInSource" > < / a > < span class = 'hs-definition' > isDestinationInSource< / span > < span class = 'hs-varid' > ex< / span > < span class = 'hs-keyglyph' > =< / span > < span class = 'hs-varid' > toConstr< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-varid' > ex< / span > < span class = 'hs-keyglyph' > ::< / span > < span class = 'hs-conid' > HPathIOException< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-varop' > ==< / span > < span class = 'hs-varid' > toConstr< / span > < span class = 'hs-conid' > DestinationInSource< / span > < span class = 'hs-layout' > {< / span > < span class = 'hs-layout' > }< / span >
< a name = "line-154" > < / a > < a name = "isFileDoesExist" > < / a > < span class = 'hs-definition' > isFileDoesExist< / span > < span class = 'hs-varid' > ex< / span > < span class = 'hs-keyglyph' > =< / span > < span class = 'hs-varid' > toConstr< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-varid' > ex< / span > < span class = 'hs-keyglyph' > ::< / span > < span class = 'hs-conid' > HPathIOException< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-varop' > ==< / span > < span class = 'hs-varid' > toConstr< / span > < span class = 'hs-conid' > FileDoesExist< / span > < span class = 'hs-layout' > {< / span > < span class = 'hs-layout' > }< / span >
< a name = "line-155" > < / a > < a name = "isDirDoesExist" > < / a > < span class = 'hs-definition' > isDirDoesExist< / span > < span class = 'hs-varid' > ex< / span > < span class = 'hs-keyglyph' > =< / span > < span class = 'hs-varid' > toConstr< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-varid' > ex< / span > < span class = 'hs-keyglyph' > ::< / span > < span class = 'hs-conid' > HPathIOException< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-varop' > ==< / span > < span class = 'hs-varid' > toConstr< / span > < span class = 'hs-conid' > DirDoesExist< / span > < span class = 'hs-layout' > {< / span > < span class = 'hs-layout' > }< / span >
< a name = "line-156" > < / a > < a name = "isInvalidOperation" > < / a > < span class = 'hs-definition' > isInvalidOperation< / span > < span class = 'hs-varid' > ex< / span > < span class = 'hs-keyglyph' > =< / span > < span class = 'hs-varid' > toConstr< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-varid' > ex< / span > < span class = 'hs-keyglyph' > ::< / span > < span class = 'hs-conid' > HPathIOException< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-varop' > ==< / span > < span class = 'hs-varid' > toConstr< / span > < span class = 'hs-conid' > InvalidOperation< / span > < span class = 'hs-layout' > {< / span > < span class = 'hs-layout' > }< / span >
< a name = "line-157" > < / a > < a name = "isCan'tOpenDirectory" > < / a > < span class = 'hs-definition' > isCan'tOpenDirectory< / span > < span class = 'hs-varid' > ex< / span > < span class = 'hs-keyglyph' > =< / span > < span class = 'hs-varid' > toConstr< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-varid' > ex< / span > < span class = 'hs-keyglyph' > ::< / span > < span class = 'hs-conid' > HPathIOException< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-varop' > ==< / span > < span class = 'hs-varid' > toConstr< / span > < span class = 'hs-conid' > Can'tOpenDirectory< / span > < span class = 'hs-layout' > {< / span > < span class = 'hs-layout' > }< / span >
< a name = "line-158" > < / a > < a name = "isCopyFailed" > < / a > < span class = 'hs-definition' > isCopyFailed< / span > < span class = 'hs-varid' > ex< / span > < span class = 'hs-keyglyph' > =< / span > < span class = 'hs-varid' > toConstr< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-varid' > ex< / span > < span class = 'hs-keyglyph' > ::< / span > < span class = 'hs-conid' > HPathIOException< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-varop' > ==< / span > < span class = 'hs-varid' > toConstr< / span > < span class = 'hs-conid' > CopyFailed< / span > < span class = 'hs-layout' > {< / span > < span class = 'hs-layout' > }< / span >
< a name = "line-159" > < / a >
< a name = "line-160" > < / a >
< a name = "line-161" > < / a >
< a name = "line-162" > < / a >
< a name = "line-163" > < / a > < span class = 'hs-comment' > ----------------------------< / span >
< a name = "line-164" > < / a > < span class = 'hs-comment' > --[ Path based functions ]--< / span >
< a name = "line-165" > < / a > < span class = 'hs-comment' > ----------------------------< / span >
< a name = "line-166" > < / a >
< a name = "line-167" > < / a >
< a name = "line-168" > < / a > < a name = "throwFileDoesExist" > < / a > < span class = 'hs-definition' > throwFileDoesExist< / span > < span class = 'hs-keyglyph' > ::< / span > < span class = 'hs-conid' > Path< / span > < span class = 'hs-conid' > Abs< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-conid' > IO< / span > < span class = 'hs-conid' > ()< / span >
< a name = "line-169" > < / a > < span class = 'hs-definition' > throwFileDoesExist< / span > < span class = 'hs-varid' > fp< / span > < span class = 'hs-keyglyph' > =< / span >
< a name = "line-170" > < / a > < span class = 'hs-varid' > whenM< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-varid' > doesFileExist< / span > < span class = 'hs-varid' > fp< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-varid' > throwIO< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-conid' > FileDoesExist< / span >
< a name = "line-171" > < / a > < span class = 'hs-varop' > .< / span > < span class = 'hs-varid' > fromAbs< / span > < span class = 'hs-varop' > $< / span > < span class = 'hs-varid' > fp< / span > < span class = 'hs-layout' > )< / span >
< a name = "line-172" > < / a >
< a name = "line-173" > < / a >
< a name = "line-174" > < / a > < a name = "throwDirDoesExist" > < / a > < span class = 'hs-definition' > throwDirDoesExist< / span > < span class = 'hs-keyglyph' > ::< / span > < span class = 'hs-conid' > Path< / span > < span class = 'hs-conid' > Abs< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-conid' > IO< / span > < span class = 'hs-conid' > ()< / span >
< a name = "line-175" > < / a > < span class = 'hs-definition' > throwDirDoesExist< / span > < span class = 'hs-varid' > fp< / span > < span class = 'hs-keyglyph' > =< / span >
< a name = "line-176" > < / a > < span class = 'hs-varid' > whenM< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-varid' > doesDirectoryExist< / span > < span class = 'hs-varid' > fp< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-varid' > throwIO< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-conid' > DirDoesExist< / span >
< a name = "line-177" > < / a > < span class = 'hs-varop' > .< / span > < span class = 'hs-varid' > fromAbs< / span > < span class = 'hs-varop' > $< / span > < span class = 'hs-varid' > fp< / span > < span class = 'hs-layout' > )< / span >
< a name = "line-178" > < / a >
< a name = "line-179" > < / a >
< a name = "line-180" > < / a > < a name = "throwFileDoesNotExist" > < / a > < span class = 'hs-definition' > throwFileDoesNotExist< / span > < span class = 'hs-keyglyph' > ::< / span > < span class = 'hs-conid' > Path< / span > < span class = 'hs-conid' > Abs< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-conid' > IO< / span > < span class = 'hs-conid' > ()< / span >
< a name = "line-181" > < / a > < span class = 'hs-definition' > throwFileDoesNotExist< / span > < span class = 'hs-varid' > fp< / span > < span class = 'hs-keyglyph' > =< / span >
< a name = "line-182" > < / a > < span class = 'hs-varid' > unlessM< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-varid' > doesFileExist< / span > < span class = 'hs-varid' > fp< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-varid' > throwIO< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-conid' > FileDoesNotExist< / span >
< a name = "line-183" > < / a > < span class = 'hs-varop' > .< / span > < span class = 'hs-varid' > fromAbs< / span > < span class = 'hs-varop' > $< / span > < span class = 'hs-varid' > fp< / span > < span class = 'hs-layout' > )< / span >
< a name = "line-184" > < / a >
< a name = "line-185" > < / a >
< a name = "line-186" > < / a > < a name = "throwDirDoesNotExist" > < / a > < span class = 'hs-definition' > throwDirDoesNotExist< / span > < span class = 'hs-keyglyph' > ::< / span > < span class = 'hs-conid' > Path< / span > < span class = 'hs-conid' > Abs< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-conid' > IO< / span > < span class = 'hs-conid' > ()< / span >
< a name = "line-187" > < / a > < span class = 'hs-definition' > throwDirDoesNotExist< / span > < span class = 'hs-varid' > fp< / span > < span class = 'hs-keyglyph' > =< / span >
< a name = "line-188" > < / a > < span class = 'hs-varid' > unlessM< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-varid' > doesDirectoryExist< / span > < span class = 'hs-varid' > fp< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-varid' > throwIO< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-conid' > DirDoesNotExist< / span >
< a name = "line-189" > < / a > < span class = 'hs-varop' > .< / span > < span class = 'hs-varid' > fromAbs< / span > < span class = 'hs-varop' > $< / span > < span class = 'hs-varid' > fp< / span > < span class = 'hs-layout' > )< / span >
< a name = "line-190" > < / a >
< a name = "line-191" > < / a >
< a name = "line-192" > < / a > < a name = "throwSameFile" > < / a > < span class = 'hs-comment' > -- |Uses `isSameFile` and throws `SameFile` if it returns True.< / span >
< a name = "line-193" > < / a > < span class = 'hs-definition' > throwSameFile< / span > < span class = 'hs-keyglyph' > ::< / span > < span class = 'hs-conid' > Path< / span > < span class = 'hs-conid' > Abs< / span >
< a name = "line-194" > < / a > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-conid' > Path< / span > < span class = 'hs-conid' > Abs< / span >
< a name = "line-195" > < / a > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-conid' > IO< / span > < span class = 'hs-conid' > ()< / span >
< a name = "line-196" > < / a > < span class = 'hs-definition' > throwSameFile< / span > < span class = 'hs-varid' > fp1< / span > < span class = 'hs-varid' > fp2< / span > < span class = 'hs-keyglyph' > =< / span >
< a name = "line-197" > < / a > < span class = 'hs-varid' > whenM< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-varid' > sameFile< / span > < span class = 'hs-varid' > fp1< / span > < span class = 'hs-varid' > fp2< / span > < span class = 'hs-layout' > )< / span >
< a name = "line-198" > < / a > < span class = 'hs-layout' > (< / span > < span class = 'hs-varid' > throwIO< / span > < span class = 'hs-varop' > $< / span > < span class = 'hs-conid' > SameFile< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-varid' > fromAbs< / span > < span class = 'hs-varid' > fp1< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-varid' > fromAbs< / span > < span class = 'hs-varid' > fp2< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-layout' > )< / span >
< a name = "line-199" > < / a >
< a name = "line-200" > < / a >
< a name = "line-201" > < / a > < a name = "sameFile" > < / a > < span class = 'hs-comment' > -- |Check if the files are the same by examining device and file id.< / span >
< a name = "line-202" > < / a > < span class = 'hs-comment' > -- This follows symbolic links.< / span >
< a name = "line-203" > < / a > < span class = 'hs-definition' > sameFile< / span > < span class = 'hs-keyglyph' > ::< / span > < span class = 'hs-conid' > Path< / span > < span class = 'hs-conid' > Abs< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-conid' > Path< / span > < span class = 'hs-conid' > Abs< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-conid' > IO< / span > < span class = 'hs-conid' > Bool< / span >
< a name = "line-204" > < / a > < span class = 'hs-definition' > sameFile< / span > < span class = 'hs-varid' > fp1< / span > < span class = 'hs-varid' > fp2< / span > < span class = 'hs-keyglyph' > =< / span >
< a name = "line-205" > < / a > < span class = 'hs-varid' > withAbsPath< / span > < span class = 'hs-varid' > fp1< / span > < span class = 'hs-varop' > $< / span > < span class = 'hs-keyglyph' > \< / span > < span class = 'hs-varid' > fp1'< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-varid' > withAbsPath< / span > < span class = 'hs-varid' > fp2< / span > < span class = 'hs-varop' > $< / span > < span class = 'hs-keyglyph' > \< / span > < span class = 'hs-varid' > fp2'< / span > < span class = 'hs-keyglyph' > -> < / span >
< a name = "line-206" > < / a > < span class = 'hs-varid' > handleIOError< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-keyglyph' > \< / span > < span class = 'hs-keyword' > _< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-varid' > return< / span > < span class = 'hs-conid' > False< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-varop' > $< / span > < span class = 'hs-keyword' > do< / span >
< a name = "line-207" > < / a > < span class = 'hs-varid' > fs1< / span > < span class = 'hs-keyglyph' > < -< / span > < span class = 'hs-varid' > getFileStatus< / span > < span class = 'hs-varid' > fp1'< / span >
< a name = "line-208" > < / a > < span class = 'hs-varid' > fs2< / span > < span class = 'hs-keyglyph' > < -< / span > < span class = 'hs-varid' > getFileStatus< / span > < span class = 'hs-varid' > fp2'< / span >
< a name = "line-209" > < / a >
< a name = "line-210" > < / a > < span class = 'hs-keyword' > if< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-conid' > PF< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-varid' > deviceID< / span > < span class = 'hs-varid' > fs1< / span > < span class = 'hs-layout' > ,< / span > < span class = 'hs-conid' > PF< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-varid' > fileID< / span > < span class = 'hs-varid' > fs1< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-varop' > ==< / span >
< a name = "line-211" > < / a > < span class = 'hs-layout' > (< / span > < span class = 'hs-conid' > PF< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-varid' > deviceID< / span > < span class = 'hs-varid' > fs2< / span > < span class = 'hs-layout' > ,< / span > < span class = 'hs-conid' > PF< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-varid' > fileID< / span > < span class = 'hs-varid' > fs2< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-layout' > )< / span >
< a name = "line-212" > < / a > < span class = 'hs-keyword' > then< / span > < span class = 'hs-varid' > return< / span > < span class = 'hs-conid' > True< / span >
< a name = "line-213" > < / a > < span class = 'hs-keyword' > else< / span > < span class = 'hs-varid' > return< / span > < span class = 'hs-conid' > False< / span >
< a name = "line-214" > < / a >
< a name = "line-215" > < / a >
< a name = "line-216" > < / a > < a name = "throwDestinationInSource" > < / a > < span class = 'hs-comment' > -- TODO: make this more robust when destination does not exist< / span >
< a name = "line-217" > < / a > < span class = 'hs-comment' > -- |Checks whether the destination directory is contained< / span >
< a name = "line-218" > < / a > < span class = 'hs-comment' > -- within the source directory by comparing the device+file ID of the< / span >
< a name = "line-219" > < / a > < span class = 'hs-comment' > -- source directory with all device+file IDs of the parent directories< / span >
< a name = "line-220" > < / a > < span class = 'hs-comment' > -- of the destination.< / span >
< a name = "line-221" > < / a > < span class = 'hs-definition' > throwDestinationInSource< / span > < span class = 'hs-keyglyph' > ::< / span > < span class = 'hs-conid' > Path< / span > < span class = 'hs-conid' > Abs< / span > < span class = 'hs-comment' > -- ^ source dir< / span >
< a name = "line-222" > < / a > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-conid' > Path< / span > < span class = 'hs-conid' > Abs< / span > < span class = 'hs-comment' > -- ^ full destination, @dirname dest@< / span >
< a name = "line-223" > < / a > < span class = 'hs-comment' > -- must exist< / span >
< a name = "line-224" > < / a > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-conid' > IO< / span > < span class = 'hs-conid' > ()< / span >
< a name = "line-225" > < / a > < span class = 'hs-definition' > throwDestinationInSource< / span > < span class = 'hs-varid' > source< / span > < span class = 'hs-varid' > dest< / span > < span class = 'hs-keyglyph' > =< / span > < span class = 'hs-keyword' > do< / span >
< a name = "line-226" > < / a > < span class = 'hs-varid' > dest'< / span > < span class = 'hs-keyglyph' > < -< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-keyglyph' > \< / span > < span class = 'hs-varid' > x< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-varid' > maybe< / span > < span class = 'hs-varid' > x< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-keyglyph' > \< / span > < span class = 'hs-varid' > y< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-varid' > x< / span > < span class = 'hs-varop' > < /> < / span > < span class = 'hs-varid' > y< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-varop' > $< / span > < span class = 'hs-varid' > basename< / span > < span class = 'hs-varid' > dest< / span > < span class = 'hs-layout' > )< / span >
< a name = "line-227" > < / a > < span class = 'hs-varop' > < $> < / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-varid' > canonicalizePath< / span > < span class = 'hs-varop' > $< / span > < span class = 'hs-varid' > dirname< / span > < span class = 'hs-varid' > dest< / span > < span class = 'hs-layout' > )< / span >
< a name = "line-228" > < / a > < span class = 'hs-varid' > dids< / span > < span class = 'hs-keyglyph' > < -< / span > < span class = 'hs-varid' > forM< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-varid' > getAllParents< / span > < span class = 'hs-varid' > dest'< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-varop' > $< / span > < span class = 'hs-keyglyph' > \< / span > < span class = 'hs-varid' > p< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-keyword' > do< / span >
< a name = "line-229" > < / a > < span class = 'hs-varid' > fs< / span > < span class = 'hs-keyglyph' > < -< / span > < span class = 'hs-conid' > PF< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-varid' > getSymbolicLinkStatus< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-varid' > fromAbs< / span > < span class = 'hs-varid' > p< / span > < span class = 'hs-layout' > )< / span >
< a name = "line-230" > < / a > < span class = 'hs-varid' > return< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-conid' > PF< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-varid' > deviceID< / span > < span class = 'hs-varid' > fs< / span > < span class = 'hs-layout' > ,< / span > < span class = 'hs-conid' > PF< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-varid' > fileID< / span > < span class = 'hs-varid' > fs< / span > < span class = 'hs-layout' > )< / span >
< a name = "line-231" > < / a > < span class = 'hs-varid' > sid< / span > < span class = 'hs-keyglyph' > < -< / span > < span class = 'hs-varid' > fmap< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-keyglyph' > \< / span > < span class = 'hs-varid' > x< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-conid' > PF< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-varid' > deviceID< / span > < span class = 'hs-varid' > x< / span > < span class = 'hs-layout' > ,< / span > < span class = 'hs-conid' > PF< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-varid' > fileID< / span > < span class = 'hs-varid' > x< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-layout' > )< / span >
< a name = "line-232" > < / a > < span class = 'hs-varop' > $< / span > < span class = 'hs-conid' > PF< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-varid' > getFileStatus< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-varid' > fromAbs< / span > < span class = 'hs-varid' > source< / span > < span class = 'hs-layout' > )< / span >
< a name = "line-233" > < / a > < span class = 'hs-varid' > when< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-varid' > elem< / span > < span class = 'hs-varid' > sid< / span > < span class = 'hs-varid' > dids< / span > < span class = 'hs-layout' > )< / span >
< a name = "line-234" > < / a > < span class = 'hs-layout' > (< / span > < span class = 'hs-varid' > throwIO< / span > < span class = 'hs-varop' > $< / span > < span class = 'hs-conid' > DestinationInSource< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-varid' > fromAbs< / span > < span class = 'hs-varid' > dest< / span > < span class = 'hs-layout' > )< / span >
< a name = "line-235" > < / a > < span class = 'hs-layout' > (< / span > < span class = 'hs-varid' > fromAbs< / span > < span class = 'hs-varid' > source< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-layout' > )< / span >
< a name = "line-236" > < / a >
< a name = "line-237" > < / a >
< a name = "line-238" > < / a > < a name = "doesFileExist" > < / a > < span class = 'hs-comment' > -- |Checks if the given file exists and is not a directory.< / span >
< a name = "line-239" > < / a > < span class = 'hs-comment' > -- Does not follow symlinks.< / span >
< a name = "line-240" > < / a > < span class = 'hs-definition' > doesFileExist< / span > < span class = 'hs-keyglyph' > ::< / span > < span class = 'hs-conid' > Path< / span > < span class = 'hs-conid' > Abs< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-conid' > IO< / span > < span class = 'hs-conid' > Bool< / span >
< a name = "line-241" > < / a > < span class = 'hs-definition' > doesFileExist< / span > < span class = 'hs-varid' > fp< / span > < span class = 'hs-keyglyph' > =< / span >
< a name = "line-242" > < / a > < span class = 'hs-varid' > handleIOError< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-keyglyph' > \< / span > < span class = 'hs-keyword' > _< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-varid' > return< / span > < span class = 'hs-conid' > False< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-varop' > $< / span > < span class = 'hs-keyword' > do< / span >
< a name = "line-243" > < / a > < span class = 'hs-varid' > fs< / span > < span class = 'hs-keyglyph' > < -< / span > < span class = 'hs-conid' > PF< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-varid' > getSymbolicLinkStatus< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-varid' > fromAbs< / span > < span class = 'hs-varid' > fp< / span > < span class = 'hs-layout' > )< / span >
< a name = "line-244" > < / a > < span class = 'hs-varid' > return< / span > < span class = 'hs-varop' > $< / span > < span class = 'hs-varid' > not< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-conid' > PF< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-varid' > isDirectory< / span > < span class = 'hs-varop' > $< / span > < span class = 'hs-varid' > fs< / span >
< a name = "line-245" > < / a >
< a name = "line-246" > < / a >
< a name = "line-247" > < / a > < a name = "doesDirectoryExist" > < / a > < span class = 'hs-comment' > -- |Checks if the given file exists and is a directory.< / span >
< a name = "line-248" > < / a > < span class = 'hs-comment' > -- Does not follow symlinks.< / span >
< a name = "line-249" > < / a > < span class = 'hs-definition' > doesDirectoryExist< / span > < span class = 'hs-keyglyph' > ::< / span > < span class = 'hs-conid' > Path< / span > < span class = 'hs-conid' > Abs< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-conid' > IO< / span > < span class = 'hs-conid' > Bool< / span >
< a name = "line-250" > < / a > < span class = 'hs-definition' > doesDirectoryExist< / span > < span class = 'hs-varid' > fp< / span > < span class = 'hs-keyglyph' > =< / span >
< a name = "line-251" > < / a > < span class = 'hs-varid' > handleIOError< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-keyglyph' > \< / span > < span class = 'hs-keyword' > _< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-varid' > return< / span > < span class = 'hs-conid' > False< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-varop' > $< / span > < span class = 'hs-keyword' > do< / span >
< a name = "line-252" > < / a > < span class = 'hs-varid' > fs< / span > < span class = 'hs-keyglyph' > < -< / span > < span class = 'hs-conid' > PF< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-varid' > getSymbolicLinkStatus< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-varid' > fromAbs< / span > < span class = 'hs-varid' > fp< / span > < span class = 'hs-layout' > )< / span >
< a name = "line-253" > < / a > < span class = 'hs-varid' > return< / span > < span class = 'hs-varop' > $< / span > < span class = 'hs-conid' > PF< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-varid' > isDirectory< / span > < span class = 'hs-varid' > fs< / span >
< a name = "line-254" > < / a >
< a name = "line-255" > < / a >
< a name = "line-256" > < / a > < a name = "isWritable" > < / a > < span class = 'hs-comment' > -- |Checks whether a file or folder is writable.< / span >
< a name = "line-257" > < / a > < span class = 'hs-definition' > isWritable< / span > < span class = 'hs-keyglyph' > ::< / span > < span class = 'hs-conid' > Path< / span > < span class = 'hs-conid' > Abs< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-conid' > IO< / span > < span class = 'hs-conid' > Bool< / span >
< a name = "line-258" > < / a > < span class = 'hs-definition' > isWritable< / span > < span class = 'hs-varid' > fp< / span > < span class = 'hs-keyglyph' > =< / span >
< a name = "line-259" > < / a > < span class = 'hs-varid' > handleIOError< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-keyglyph' > \< / span > < span class = 'hs-keyword' > _< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-varid' > return< / span > < span class = 'hs-conid' > False< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-varop' > $< / span >
< a name = "line-260" > < / a > < span class = 'hs-varid' > fileAccess< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-varid' > fromAbs< / span > < span class = 'hs-varid' > fp< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-conid' > False< / span > < span class = 'hs-conid' > True< / span > < span class = 'hs-conid' > False< / span >
< a name = "line-261" > < / a >
< a name = "line-262" > < / a >
< a name = "line-263" > < / a > < a name = "canOpenDirectory" > < / a > < span class = 'hs-comment' > -- |Checks whether the directory at the given path exists and can be< / span >
< a name = "line-264" > < / a > < span class = 'hs-comment' > -- opened. This invokes `openDirStream` which follows symlinks.< / span >
< a name = "line-265" > < / a > < span class = 'hs-definition' > canOpenDirectory< / span > < span class = 'hs-keyglyph' > ::< / span > < span class = 'hs-conid' > Path< / span > < span class = 'hs-conid' > Abs< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-conid' > IO< / span > < span class = 'hs-conid' > Bool< / span >
< a name = "line-266" > < / a > < span class = 'hs-definition' > canOpenDirectory< / span > < span class = 'hs-varid' > fp< / span > < span class = 'hs-keyglyph' > =< / span >
< a name = "line-267" > < / a > < span class = 'hs-varid' > handleIOError< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-keyglyph' > \< / span > < span class = 'hs-keyword' > _< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-varid' > return< / span > < span class = 'hs-conid' > False< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-varop' > $< / span > < span class = 'hs-keyword' > do< / span >
< a name = "line-268" > < / a > < span class = 'hs-varid' > bracket< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-conid' > PFD< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-varid' > openDirStream< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-varid' > fromAbs< / span > < span class = 'hs-varop' > $< / span > < span class = 'hs-varid' > fp< / span > < span class = 'hs-layout' > )< / span >
< a name = "line-269" > < / a > < span class = 'hs-conid' > PFD< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-varid' > closeDirStream< / span >
< a name = "line-270" > < / a > < span class = 'hs-layout' > (< / span > < span class = 'hs-keyglyph' > \< / span > < span class = 'hs-keyword' > _< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-varid' > return< / span > < span class = 'hs-conid' > ()< / span > < span class = 'hs-layout' > )< / span >
< a name = "line-271" > < / a > < span class = 'hs-varid' > return< / span > < span class = 'hs-conid' > True< / span >
< a name = "line-272" > < / a >
< a name = "line-273" > < / a >
< a name = "line-274" > < / a > < a name = "throwCantOpenDirectory" > < / a > < span class = 'hs-comment' > -- |Throws a `Can'tOpenDirectory` HPathIOException if the directory at the given< / span >
< a name = "line-275" > < / a > < span class = 'hs-comment' > -- path cannot be opened.< / span >
< a name = "line-276" > < / a > < span class = 'hs-definition' > throwCantOpenDirectory< / span > < span class = 'hs-keyglyph' > ::< / span > < span class = 'hs-conid' > Path< / span > < span class = 'hs-conid' > Abs< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-conid' > IO< / span > < span class = 'hs-conid' > ()< / span >
< a name = "line-277" > < / a > < span class = 'hs-definition' > throwCantOpenDirectory< / span > < span class = 'hs-varid' > fp< / span > < span class = 'hs-keyglyph' > =< / span >
< a name = "line-278" > < / a > < span class = 'hs-varid' > unlessM< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-varid' > canOpenDirectory< / span > < span class = 'hs-varid' > fp< / span > < span class = 'hs-layout' > )< / span >
< a name = "line-279" > < / a > < span class = 'hs-layout' > (< / span > < span class = 'hs-varid' > throwIO< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-conid' > Can'tOpenDirectory< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-varid' > fromAbs< / span > < span class = 'hs-varop' > $< / span > < span class = 'hs-varid' > fp< / span > < span class = 'hs-layout' > )< / span >
< a name = "line-280" > < / a >
< a name = "line-281" > < / a >
< a name = "line-282" > < / a >
< a name = "line-283" > < / a > < span class = 'hs-comment' > --------------------------------< / span >
< a name = "line-284" > < / a > < span class = 'hs-comment' > --[ Error handling functions ]--< / span >
< a name = "line-285" > < / a > < span class = 'hs-comment' > --------------------------------< / span >
< a name = "line-286" > < / a >
< a name = "line-287" > < / a >
< a name = "line-288" > < / a > < a name = "catchErrno" > < / a > < span class = 'hs-comment' > -- |Carries out an action, then checks if there is an IOException and< / span >
< a name = "line-289" > < / a > < span class = 'hs-comment' > -- a specific errno. If so, then it carries out another action, otherwise< / span >
< a name = "line-290" > < / a > < span class = 'hs-comment' > -- it rethrows the error.< / span >
< a name = "line-291" > < / a > < span class = 'hs-definition' > catchErrno< / span > < span class = 'hs-keyglyph' > ::< / span > < span class = 'hs-keyglyph' > [< / span > < span class = 'hs-conid' > Errno< / span > < span class = 'hs-keyglyph' > ]< / span > < span class = 'hs-comment' > -- ^ errno to catch< / span >
< a name = "line-292" > < / a > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-conid' > IO< / span > < span class = 'hs-varid' > a< / span > < span class = 'hs-comment' > -- ^ action to try, which can raise an IOException< / span >
< a name = "line-293" > < / a > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-conid' > IO< / span > < span class = 'hs-varid' > a< / span > < span class = 'hs-comment' > -- ^ action to carry out in case of an IOException and< / span >
< a name = "line-294" > < / a > < span class = 'hs-comment' > -- if errno matches< / span >
< a name = "line-295" > < / a > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-conid' > IO< / span > < span class = 'hs-varid' > a< / span >
< a name = "line-296" > < / a > < span class = 'hs-definition' > catchErrno< / span > < span class = 'hs-varid' > en< / span > < span class = 'hs-varid' > a1< / span > < span class = 'hs-varid' > a2< / span > < span class = 'hs-keyglyph' > =< / span >
< a name = "line-297" > < / a > < span class = 'hs-varid' > catchIOError< / span > < span class = 'hs-varid' > a1< / span > < span class = 'hs-varop' > $< / span > < span class = 'hs-keyglyph' > \< / span > < span class = 'hs-varid' > e< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-keyword' > do< / span >
< a name = "line-298" > < / a > < span class = 'hs-varid' > errno< / span > < span class = 'hs-keyglyph' > < -< / span > < span class = 'hs-varid' > getErrno< / span >
< a name = "line-299" > < / a > < span class = 'hs-keyword' > if< / span > < span class = 'hs-varid' > errno< / span > < span class = 'hs-varop' > `elem`< / span > < span class = 'hs-varid' > en< / span >
< a name = "line-300" > < / a > < span class = 'hs-keyword' > then< / span > < span class = 'hs-varid' > a2< / span >
< a name = "line-301" > < / a > < span class = 'hs-keyword' > else< / span > < span class = 'hs-varid' > ioError< / span > < span class = 'hs-varid' > e< / span >
< a name = "line-302" > < / a >
< a name = "line-303" > < / a >
< a name = "line-304" > < / a > < a name = "rethrowErrnoAs" > < / a > < span class = 'hs-comment' > -- |Execute the given action and retrow IO exceptions as a new Exception< / span >
< a name = "line-305" > < / a > < span class = 'hs-comment' > -- that have the given errno. If errno does not match the exception is rethrown< / span >
< a name = "line-306" > < / a > < span class = 'hs-comment' > -- as is.< / span >
< a name = "line-307" > < / a > < span class = 'hs-definition' > rethrowErrnoAs< / span > < span class = 'hs-keyglyph' > ::< / span > < span class = 'hs-conid' > Exception< / span > < span class = 'hs-varid' > e< / span >
< a name = "line-308" > < / a > < span class = 'hs-keyglyph' > => < / span > < span class = 'hs-keyglyph' > [< / span > < span class = 'hs-conid' > Errno< / span > < span class = 'hs-keyglyph' > ]< / span > < span class = 'hs-comment' > -- ^ errno to catch< / span >
< a name = "line-309" > < / a > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-varid' > e< / span > < span class = 'hs-comment' > -- ^ rethrow as if errno matches< / span >
< a name = "line-310" > < / a > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-conid' > IO< / span > < span class = 'hs-varid' > a< / span > < span class = 'hs-comment' > -- ^ action to try< / span >
< a name = "line-311" > < / a > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-conid' > IO< / span > < span class = 'hs-varid' > a< / span >
< a name = "line-312" > < / a > < span class = 'hs-definition' > rethrowErrnoAs< / span > < span class = 'hs-varid' > en< / span > < span class = 'hs-varid' > fmex< / span > < span class = 'hs-varid' > action< / span > < span class = 'hs-keyglyph' > =< / span > < span class = 'hs-varid' > catchErrno< / span > < span class = 'hs-varid' > en< / span > < span class = 'hs-varid' > action< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-varid' > throwIO< / span > < span class = 'hs-varid' > fmex< / span > < span class = 'hs-layout' > )< / span >
< a name = "line-313" > < / a >
< a name = "line-314" > < / a >
< a name = "line-315" > < / a >
< a name = "line-316" > < / a > < a name = "handleIOError" > < / a > < span class = 'hs-comment' > -- |Like `catchIOError`, with arguments swapped.< / span >
< a name = "line-317" > < / a > < span class = 'hs-definition' > handleIOError< / span > < span class = 'hs-keyglyph' > ::< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-conid' > IOError< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-conid' > IO< / span > < span class = 'hs-varid' > a< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-conid' > IO< / span > < span class = 'hs-varid' > a< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-conid' > IO< / span > < span class = 'hs-varid' > a< / span >
< a name = "line-318" > < / a > < span class = 'hs-definition' > handleIOError< / span > < span class = 'hs-keyglyph' > =< / span > < span class = 'hs-varid' > flip< / span > < span class = 'hs-varid' > catchIOError< / span >
< a name = "line-319" > < / a >
< a name = "line-320" > < / a >
< a name = "line-321" > < / a > < a name = "bracketeer" > < / a > < span class = 'hs-comment' > -- |Like `bracket`, but allows to have different clean-up< / span >
< a name = "line-322" > < / a > < span class = 'hs-comment' > -- actions depending on whether the in-between computation< / span >
< a name = "line-323" > < / a > < span class = 'hs-comment' > -- has raised an exception or not. < / span >
< a name = "line-324" > < / a > < span class = 'hs-definition' > bracketeer< / span > < span class = 'hs-keyglyph' > ::< / span > < span class = 'hs-conid' > IO< / span > < span class = 'hs-varid' > a< / span > < span class = 'hs-comment' > -- ^ computation to run first< / span >
< a name = "line-325" > < / a > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-varid' > a< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-conid' > IO< / span > < span class = 'hs-varid' > b< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-comment' > -- ^ computation to run last, when< / span >
< a name = "line-326" > < / a > < span class = 'hs-comment' > -- no exception was raised< / span >
< a name = "line-327" > < / a > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-varid' > a< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-conid' > IO< / span > < span class = 'hs-varid' > b< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-comment' > -- ^ computation to run last,< / span >
< a name = "line-328" > < / a > < span class = 'hs-comment' > -- when an exception was raised< / span >
< a name = "line-329" > < / a > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-varid' > a< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-conid' > IO< / span > < span class = 'hs-varid' > c< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-comment' > -- ^ computation to run in-between< / span >
< a name = "line-330" > < / a > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-conid' > IO< / span > < span class = 'hs-varid' > c< / span >
< a name = "line-331" > < / a > < span class = 'hs-definition' > bracketeer< / span > < span class = 'hs-varid' > before< / span > < span class = 'hs-varid' > after< / span > < span class = 'hs-varid' > afterEx< / span > < span class = 'hs-varid' > thing< / span > < span class = 'hs-keyglyph' > =< / span >
< a name = "line-332" > < / a > < span class = 'hs-varid' > mask< / span > < span class = 'hs-varop' > $< / span > < span class = 'hs-keyglyph' > \< / span > < span class = 'hs-varid' > restore< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-keyword' > do< / span >
< a name = "line-333" > < / a > < span class = 'hs-varid' > a< / span > < span class = 'hs-keyglyph' > < -< / span > < span class = 'hs-varid' > before< / span >
< a name = "line-334" > < / a > < span class = 'hs-varid' > r< / span > < span class = 'hs-keyglyph' > < -< / span > < span class = 'hs-varid' > restore< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-varid' > thing< / span > < span class = 'hs-varid' > a< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-varop' > `onException`< / span > < span class = 'hs-varid' > afterEx< / span > < span class = 'hs-varid' > a< / span >
< a name = "line-335" > < / a > < span class = 'hs-keyword' > _< / span > < span class = 'hs-keyglyph' > < -< / span > < span class = 'hs-varid' > after< / span > < span class = 'hs-varid' > a< / span >
< a name = "line-336" > < / a > < span class = 'hs-varid' > return< / span > < span class = 'hs-varid' > r< / span >
< a name = "line-337" > < / a >
< a name = "line-338" > < / a >
< a name = "line-339" > < / a > < a name = "reactOnError" > < / a > < span class = 'hs-definition' > reactOnError< / span > < span class = 'hs-keyglyph' > ::< / span > < span class = 'hs-conid' > IO< / span > < span class = 'hs-varid' > a< / span >
< a name = "line-340" > < / a > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-keyglyph' > [< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-conid' > IOErrorType< / span > < span class = 'hs-layout' > ,< / span > < span class = 'hs-conid' > IO< / span > < span class = 'hs-varid' > a< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-keyglyph' > ]< / span > < span class = 'hs-comment' > -- ^ reaction on IO errors< / span >
< a name = "line-341" > < / a > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-keyglyph' > [< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-conid' > HPathIOException< / span > < span class = 'hs-layout' > ,< / span > < span class = 'hs-conid' > IO< / span > < span class = 'hs-varid' > a< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-keyglyph' > ]< / span > < span class = 'hs-comment' > -- ^ reaction on HPathIOException< / span >
< a name = "line-342" > < / a > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-conid' > IO< / span > < span class = 'hs-varid' > a< / span >
< a name = "line-343" > < / a > < span class = 'hs-definition' > reactOnError< / span > < span class = 'hs-varid' > a< / span > < span class = 'hs-varid' > ios< / span > < span class = 'hs-varid' > fmios< / span > < span class = 'hs-keyglyph' > =< / span >
< a name = "line-344" > < / a > < span class = 'hs-varid' > a< / span > < span class = 'hs-varop' > `catches`< / span > < span class = 'hs-keyglyph' > [< / span > < span class = 'hs-varid' > iohandler< / span > < span class = 'hs-layout' > ,< / span > < span class = 'hs-varid' > fmiohandler< / span > < span class = 'hs-keyglyph' > ]< / span >
< a name = "line-345" > < / a > < span class = 'hs-keyword' > where< / span >
< a name = "line-346" > < / a > < span class = 'hs-varid' > iohandler< / span > < span class = 'hs-keyglyph' > =< / span > < span class = 'hs-conid' > Handler< / span > < span class = 'hs-varop' > $< / span >
< a name = "line-347" > < / a > < span class = 'hs-keyglyph' > \< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-varid' > ex< / span > < span class = 'hs-keyglyph' > ::< / span > < span class = 'hs-conid' > IOException< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-keyglyph' > -> < / span >
< a name = "line-348" > < / a > < span class = 'hs-varid' > foldr< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-keyglyph' > \< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-varid' > t< / span > < span class = 'hs-layout' > ,< / span > < span class = 'hs-varid' > a'< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-varid' > y< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-keyword' > if< / span > < span class = 'hs-varid' > ioeGetErrorType< / span > < span class = 'hs-varid' > ex< / span > < span class = 'hs-varop' > ==< / span > < span class = 'hs-varid' > t< / span >
< a name = "line-349" > < / a > < span class = 'hs-keyword' > then< / span > < span class = 'hs-varid' > a'< / span >
< a name = "line-350" > < / a > < span class = 'hs-keyword' > else< / span > < span class = 'hs-varid' > y< / span > < span class = 'hs-layout' > )< / span >
< a name = "line-351" > < / a > < span class = 'hs-layout' > (< / span > < span class = 'hs-varid' > throwIO< / span > < span class = 'hs-varid' > ex< / span > < span class = 'hs-layout' > )< / span >
< a name = "line-352" > < / a > < span class = 'hs-varid' > ios< / span >
< a name = "line-353" > < / a > < span class = 'hs-varid' > fmiohandler< / span > < span class = 'hs-keyglyph' > =< / span > < span class = 'hs-conid' > Handler< / span > < span class = 'hs-varop' > $< / span >
< a name = "line-354" > < / a > < span class = 'hs-keyglyph' > \< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-varid' > ex< / span > < span class = 'hs-keyglyph' > ::< / span > < span class = 'hs-conid' > HPathIOException< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-keyglyph' > -> < / span >
< a name = "line-355" > < / a > < span class = 'hs-varid' > foldr< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-keyglyph' > \< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-varid' > t< / span > < span class = 'hs-layout' > ,< / span > < span class = 'hs-varid' > a'< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-varid' > y< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-keyword' > if< / span > < span class = 'hs-varid' > toConstr< / span > < span class = 'hs-varid' > ex< / span > < span class = 'hs-varop' > ==< / span > < span class = 'hs-varid' > toConstr< / span > < span class = 'hs-varid' > t< / span >
< a name = "line-356" > < / a > < span class = 'hs-keyword' > then< / span > < span class = 'hs-varid' > a'< / span >
< a name = "line-357" > < / a > < span class = 'hs-keyword' > else< / span > < span class = 'hs-varid' > y< / span > < span class = 'hs-layout' > )< / span >
< a name = "line-358" > < / a > < span class = 'hs-layout' > (< / span > < span class = 'hs-varid' > throwIO< / span > < span class = 'hs-varid' > ex< / span > < span class = 'hs-layout' > )< / span >
< a name = "line-359" > < / a > < span class = 'hs-varid' > fmios< / span >
< / pre > < / body >
< / html >