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/System/Posix/Directory/Traversals.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 : System.Posix.Directory.Traversals< / span >
< a name = "line-3" > < / a > < span class = 'hs-comment' > -- Copyright : © 2016 Julian Ospald< / span >
< a name = "line-4" > < / a > < span class = 'hs-comment' > -- License : BSD3< / span >
< 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' > -- Traversal and read operations on directories.< / span >
< a name = "line-11" > < / a >
< a name = "line-12" > < / a >
2016-06-05 14:22:57 +00:00
< a name = "line-13" > < / a > < span class = 'hs-comment' > {-# LANGUAGE CPP #-}< / span >
< a name = "line-14" > < / a > < span class = 'hs-comment' > {-# LANGUAGE ForeignFunctionInterface #-}< / span >
< a name = "line-15" > < / a > < span class = 'hs-comment' > {-# LANGUAGE OverloadedStrings #-}< / span >
< a name = "line-16" > < / a > < span class = 'hs-comment' > {-# LANGUAGE PackageImports #-}< / span >
< a name = "line-17" > < / a > < span class = 'hs-comment' > {-# LANGUAGE TupleSections #-}< / span >
< a name = "line-18" > < / a > < span class = 'hs-comment' > {-# LANGUAGE ViewPatterns #-}< / span >
< a name = "line-19" > < / a >
< a name = "line-20" > < / a > < span class = 'hs-comment' > {-# OPTIONS_GHC -Wall #-}< / span >
2016-06-01 12:52:48 +00:00
< a name = "line-21" > < / a >
2016-06-05 14:22:57 +00:00
< a name = "line-22" > < / a >
< a name = "line-23" > < / a > < span class = 'hs-keyword' > module< / 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' > Traversals< / span > < span class = 'hs-layout' > (< / span >
< a name = "line-24" > < / a >
< a name = "line-25" > < / a > < span class = 'hs-varid' > getDirectoryContents< / span >
< a name = "line-26" > < / a > < span class = 'hs-layout' > ,< / span > < span class = 'hs-varid' > getDirectoryContents'< / span >
< a name = "line-27" > < / a >
< a name = "line-28" > < / a > < span class = 'hs-layout' > ,< / span > < span class = 'hs-varid' > allDirectoryContents< / span >
< a name = "line-29" > < / a > < span class = 'hs-layout' > ,< / span > < span class = 'hs-varid' > allDirectoryContents'< / span >
< a name = "line-30" > < / a > < span class = 'hs-layout' > ,< / span > < span class = 'hs-varid' > traverseDirectory< / span >
< a name = "line-31" > < / a >
< a name = "line-32" > < / a > < span class = 'hs-comment' > -- lower-level stuff< / span >
< a name = "line-33" > < / a > < span class = 'hs-layout' > ,< / span > < span class = 'hs-varid' > readDirEnt< / span >
< a name = "line-34" > < / a > < span class = 'hs-layout' > ,< / span > < span class = 'hs-varid' > packDirStream< / span >
< a name = "line-35" > < / a > < span class = 'hs-layout' > ,< / span > < span class = 'hs-varid' > unpackDirStream< / span >
< a name = "line-36" > < / a > < span class = 'hs-layout' > ,< / span > < span class = 'hs-varid' > fdOpendir< / span >
< a name = "line-37" > < / a >
< a name = "line-38" > < / a > < span class = 'hs-layout' > ,< / span > < span class = 'hs-varid' > realpath< / span >
< a name = "line-39" > < / a > < span class = 'hs-layout' > )< / span > < span class = 'hs-keyword' > where< / span >
< a name = "line-40" > < / a >
< a name = "line-41" > < / a >
< a name = "line-42" > < / a > < span class = 'hs-cpp' > #if __GLASGOW_HASKELL__ < 710< / span >
< a name = "line-43" > < / a > < span class = 'hs-keyword' > import< / span > < span class = 'hs-conid' > Control< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-conid' > Applicative< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-varop' > < $> < / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-layout' > )< / span >
< a name = "line-44" > < / a > < span class = 'hs-cpp' > #endif< / span >
< a name = "line-45" > < / 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-46" > < / 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' > FilePath< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-varop' > < /> < / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-layout' > )< / span >
< a name = "line-47" > < / 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' > Directory< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-conid' > Foreign< / span >
< a name = "line-48" > < / a >
< a name = "line-49" > < / 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-keyword' > as< / span > < span class = 'hs-conid' > Posix< / span >
< a name = "line-50" > < / 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-51" > < / 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-52" > < / a > < span class = 'hs-keyword' > import< / span > < span class = 'hs-keyword' > qualified< / 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' > Char8< / span > < span class = 'hs-keyword' > as< / span > < span class = 'hs-conid' > BS< / span >
< a name = "line-53" > < / 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' > ByteString< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-conid' > FilePath< / span >
< a name = "line-54" > < / 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' > Directory< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-conid' > ByteString< / span > < span class = 'hs-keyword' > as< / span > < span class = 'hs-conid' > PosixBS< / span >
< a name = "line-55" > < / 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-56" > < / a >
< a name = "line-57" > < / 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' > Unsafe< / span >
< a name = "line-58" > < / a > < span class = 'hs-keyword' > import< / span > < span class = 'hs-str' > "unix"< / 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' > IO< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-conid' > ByteString< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-varid' > closeFd< / span > < span class = 'hs-layout' > )< / span >
< a name = "line-59" > < / a > < span class = 'hs-keyword' > import< / span > < span class = 'hs-conid' > Unsafe< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-conid' > Coerce< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-varid' > unsafeCoerce< / span > < span class = 'hs-layout' > )< / span >
< a name = "line-60" > < / 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-61" > < / 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' > String< / span >
< a name = "line-62" > < / 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' > Types< / span >
< a name = "line-63" > < / a > < span class = 'hs-keyword' > import< / span > < span class = 'hs-conid' > Foreign< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-conid' > Marshal< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-conid' > Alloc< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-varid' > alloca< / span > < span class = 'hs-layout' > ,< / span > < span class = 'hs-varid' > allocaBytes< / span > < span class = 'hs-layout' > )< / span >
< a name = "line-64" > < / a > < span class = 'hs-keyword' > import< / span > < span class = 'hs-conid' > Foreign< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-conid' > Ptr< / span >
< a name = "line-65" > < / a > < span class = 'hs-keyword' > import< / span > < span class = 'hs-conid' > Foreign< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-conid' > Storable< / span >
< a name = "line-66" > < / a >
2016-06-01 12:52:48 +00:00
< a name = "line-67" > < / a >
2016-06-05 14:22:57 +00:00
< a name = "line-68" > < / a >
< a name = "line-69" > < / a >
< a name = "line-70" > < / a > < span class = 'hs-comment' > ----------------------------------------------------------< / span >
< a name = "line-71" > < / a >
< a name = "line-72" > < / a > < a name = "allDirectoryContents" > < / a > < span class = 'hs-comment' > -- | Get all files from a directory and its subdirectories.< / span >
2016-06-01 12:52:48 +00:00
< a name = "line-73" > < / a > < span class = 'hs-comment' > --< / span >
2016-06-05 14:22:57 +00:00
< a name = "line-74" > < / a > < span class = 'hs-comment' > -- Upon entering a directory, 'allDirectoryContents' will get all entries< / span >
< a name = "line-75" > < / a > < span class = 'hs-comment' > -- strictly. However the returned list is lazy in that directories will only< / span >
< a name = "line-76" > < / a > < span class = 'hs-comment' > -- be accessed on demand.< / span >
< a name = "line-77" > < / a > < span class = 'hs-comment' > --< / span >
< a name = "line-78" > < / a > < span class = 'hs-comment' > -- Follows symbolic links for the input dir.< / span >
< a name = "line-79" > < / a > < span class = 'hs-definition' > allDirectoryContents< / span > < span class = 'hs-keyglyph' > ::< / span > < span class = 'hs-conid' > RawFilePath< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-conid' > IO< / span > < span class = 'hs-keyglyph' > [< / span > < span class = 'hs-conid' > RawFilePath< / span > < span class = 'hs-keyglyph' > ]< / span >
< a name = "line-80" > < / a > < span class = 'hs-definition' > allDirectoryContents< / span > < span class = 'hs-varid' > topdir< / span > < span class = 'hs-keyglyph' > =< / span > < span class = 'hs-keyword' > do< / span >
< a name = "line-81" > < / a > < span class = 'hs-varid' > namesAndTypes< / span > < span class = 'hs-keyglyph' > < -< / span > < span class = 'hs-varid' > getDirectoryContents< / span > < span class = 'hs-varid' > topdir< / span >
< a name = "line-82" > < / a > < span class = 'hs-keyword' > let< / span > < span class = 'hs-varid' > properNames< / span > < span class = 'hs-keyglyph' > =< / span > < span class = 'hs-varid' > filter< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-varop' > `notElem`< / span > < span class = 'hs-keyglyph' > [< / span > < span class = 'hs-str' > "."< / span > < span class = 'hs-layout' > ,< / span > < span class = 'hs-str' > ".."< / span > < span class = 'hs-keyglyph' > ]< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-varid' > snd< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-varid' > namesAndTypes< / span >
< a name = "line-83" > < / a > < span class = 'hs-varid' > paths< / span > < span class = 'hs-keyglyph' > < -< / span > < span class = 'hs-varid' > forM< / span > < span class = 'hs-varid' > properNames< / span > < span class = 'hs-varop' > $< / span > < span class = 'hs-keyglyph' > \< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-varid' > typ< / span > < span class = 'hs-layout' > ,< / span > < span class = 'hs-varid' > name< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-varid' > unsafeInterleaveIO< / span > < span class = 'hs-varop' > $< / span > < span class = 'hs-keyword' > do< / span >
< a name = "line-84" > < / a > < span class = 'hs-keyword' > let< / span > < span class = 'hs-varid' > path< / span > < span class = 'hs-keyglyph' > =< / span > < span class = 'hs-varid' > topdir< / span > < span class = 'hs-varop' > < /> < / span > < span class = 'hs-varid' > name< / span >
< a name = "line-85" > < / a > < span class = 'hs-keyword' > case< / span > < span class = 'hs-conid' > ()< / span > < span class = 'hs-keyword' > of< / span >
< a name = "line-86" > < / a > < span class = 'hs-conid' > ()< / span > < span class = 'hs-keyglyph' > |< / span > < span class = 'hs-varid' > typ< / span > < span class = 'hs-varop' > ==< / span > < span class = 'hs-varid' > dtDir< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-varid' > allDirectoryContents< / span > < span class = 'hs-varid' > path< / span >
< a name = "line-87" > < / a > < span class = 'hs-keyglyph' > |< / span > < span class = 'hs-varid' > typ< / span > < span class = 'hs-varop' > ==< / span > < span class = 'hs-varid' > dtUnknown< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-keyword' > do< / span >
< a name = "line-88" > < / a > < span class = 'hs-varid' > isDir< / span > < span class = 'hs-keyglyph' > < -< / span > < span class = 'hs-varid' > isDirectory< / span > < span class = 'hs-varop' > < $> < / span > < span class = 'hs-varid' > getFileStatus< / span > < span class = 'hs-varid' > path< / span >
< a name = "line-89" > < / a > < span class = 'hs-keyword' > if< / span > < span class = 'hs-varid' > isDir< / span >
< a name = "line-90" > < / a > < span class = 'hs-keyword' > then< / span > < span class = 'hs-varid' > allDirectoryContents< / span > < span class = 'hs-varid' > path< / span >
< a name = "line-91" > < / a > < span class = 'hs-keyword' > else< / span > < span class = 'hs-varid' > return< / span > < span class = 'hs-keyglyph' > [< / span > < span class = 'hs-varid' > path< / span > < span class = 'hs-keyglyph' > ]< / span >
< a name = "line-92" > < / a > < span class = 'hs-keyglyph' > |< / span > < span class = 'hs-varid' > otherwise< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-varid' > return< / span > < span class = 'hs-keyglyph' > [< / span > < span class = 'hs-varid' > path< / span > < span class = 'hs-keyglyph' > ]< / span >
< a name = "line-93" > < / a > < span class = 'hs-varid' > return< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-varid' > topdir< / span > < span class = 'hs-conop' > :< / span > < span class = 'hs-varid' > concat< / span > < span class = 'hs-varid' > paths< / span > < span class = 'hs-layout' > )< / span >
< a name = "line-94" > < / a >
< a name = "line-95" > < / a > < a name = "allDirectoryContents'" > < / a > < span class = 'hs-comment' > -- | Get all files from a directory and its subdirectories strictly.< / span >
< a name = "line-96" > < / a > < span class = 'hs-comment' > --< / span >
< a name = "line-97" > < / a > < span class = 'hs-comment' > -- Follows symbolic links for the input dir.< / span >
< a name = "line-98" > < / a > < span class = 'hs-definition' > allDirectoryContents'< / span > < span class = 'hs-keyglyph' > ::< / span > < span class = 'hs-conid' > RawFilePath< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-conid' > IO< / span > < span class = 'hs-keyglyph' > [< / span > < span class = 'hs-conid' > RawFilePath< / span > < span class = 'hs-keyglyph' > ]< / span >
< a name = "line-99" > < / a > < span class = 'hs-definition' > allDirectoryContents'< / span > < span class = 'hs-keyglyph' > =< / span > < span class = 'hs-varid' > fmap< / span > < span class = 'hs-varid' > reverse< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-varid' > traverseDirectory< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-keyglyph' > \< / span > < span class = 'hs-varid' > acc< / span > < span class = 'hs-varid' > fp< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-varid' > return< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-varid' > fp< / span > < span class = 'hs-conop' > :< / span > < span class = 'hs-varid' > acc< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-conid' > []< / span >
< a name = "line-100" > < / a > < span class = 'hs-comment' > -- this uses traverseDirectory because it's more efficient than forcing the< / span >
< a name = "line-101" > < / a > < span class = 'hs-comment' > -- lazy version.< / span >
< a name = "line-102" > < / a >
< a name = "line-103" > < / a > < a name = "traverseDirectory" > < / a > < span class = 'hs-comment' > -- | Recursively apply the 'action' to the parent directory and all< / span >
< a name = "line-104" > < / a > < span class = 'hs-comment' > -- files/subdirectories.< / span >
< a name = "line-105" > < / a > < span class = 'hs-comment' > --< / span >
< a name = "line-106" > < / a > < span class = 'hs-comment' > -- This function allows for memory-efficient traversals.< / span >
< a name = "line-107" > < / a > < span class = 'hs-comment' > --< / span >
< a name = "line-108" > < / a > < span class = 'hs-comment' > -- Follows symbolic links for the input dir.< / span >
< a name = "line-109" > < / a > < span class = 'hs-definition' > traverseDirectory< / span > < span class = 'hs-keyglyph' > ::< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-varid' > s< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-conid' > RawFilePath< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-conid' > IO< / span > < span class = 'hs-varid' > s< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-varid' > s< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-conid' > RawFilePath< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-conid' > IO< / span > < span class = 'hs-varid' > s< / span >
< a name = "line-110" > < / a > < span class = 'hs-definition' > traverseDirectory< / span > < span class = 'hs-varid' > act< / span > < span class = 'hs-varid' > s0< / span > < span class = 'hs-varid' > topdir< / span > < span class = 'hs-keyglyph' > =< / span > < span class = 'hs-varid' > toploop< / span >
< a name = "line-111" > < / a > < span class = 'hs-keyword' > where< / span >
< a name = "line-112" > < / a > < span class = 'hs-varid' > toploop< / span > < span class = 'hs-keyglyph' > =< / span > < span class = 'hs-keyword' > do< / span >
< a name = "line-113" > < / a > < span class = 'hs-varid' > isDir< / span > < span class = 'hs-keyglyph' > < -< / span > < span class = 'hs-varid' > isDirectory< / span > < span class = 'hs-varop' > < $> < / span > < span class = 'hs-varid' > getFileStatus< / span > < span class = 'hs-varid' > topdir< / span >
< a name = "line-114" > < / a > < span class = 'hs-varid' > s'< / span > < span class = 'hs-keyglyph' > < -< / span > < span class = 'hs-varid' > act< / span > < span class = 'hs-varid' > s0< / span > < span class = 'hs-varid' > topdir< / span >
< a name = "line-115" > < / a > < span class = 'hs-keyword' > if< / span > < span class = 'hs-varid' > isDir< / span > < span class = 'hs-keyword' > then< / span > < span class = 'hs-varid' > actOnDirContents< / span > < span class = 'hs-varid' > topdir< / span > < span class = 'hs-varid' > s'< / span > < span class = 'hs-varid' > loop< / span >
< a name = "line-116" > < / a > < span class = 'hs-keyword' > else< / span > < span class = 'hs-varid' > return< / span > < span class = 'hs-varid' > s'< / span >
< a name = "line-117" > < / a > < span class = 'hs-varid' > loop< / span > < span class = 'hs-varid' > typ< / span > < span class = 'hs-varid' > path< / span > < span class = 'hs-varid' > acc< / span > < span class = 'hs-keyglyph' > =< / span > < span class = 'hs-keyword' > do< / span >
< a name = "line-118" > < / a > < span class = 'hs-varid' > isDir< / span > < span class = 'hs-keyglyph' > < -< / span > < span class = 'hs-keyword' > case< / span > < span class = 'hs-conid' > ()< / span > < span class = 'hs-keyword' > of< / span >
< a name = "line-119" > < / a > < span class = 'hs-conid' > ()< / span > < span class = 'hs-keyglyph' > |< / span > < span class = 'hs-varid' > typ< / span > < span class = 'hs-varop' > ==< / span > < span class = 'hs-varid' > dtDir< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-varid' > return< / span > < span class = 'hs-conid' > True< / span >
< a name = "line-120" > < / a > < span class = 'hs-keyglyph' > |< / span > < span class = 'hs-varid' > typ< / span > < span class = 'hs-varop' > ==< / span > < span class = 'hs-varid' > dtUnknown< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-varid' > isDirectory< / span > < span class = 'hs-varop' > < $> < / span > < span class = 'hs-varid' > getFileStatus< / span > < span class = 'hs-varid' > path< / span >
< a name = "line-121" > < / a > < span class = 'hs-keyglyph' > |< / span > < span class = 'hs-varid' > otherwise< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-varid' > return< / span > < span class = 'hs-conid' > False< / span >
< a name = "line-122" > < / a > < span class = 'hs-keyword' > if< / span > < span class = 'hs-varid' > isDir< / span >
< a name = "line-123" > < / a > < span class = 'hs-keyword' > then< / span > < span class = 'hs-varid' > act< / span > < span class = 'hs-varid' > acc< / span > < span class = 'hs-varid' > path< / span > < span class = 'hs-varop' > > > =< / span > < span class = 'hs-keyglyph' > \< / span > < span class = 'hs-varid' > acc'< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-varid' > actOnDirContents< / span > < span class = 'hs-varid' > path< / span > < span class = 'hs-varid' > acc'< / span > < span class = 'hs-varid' > loop< / span >
< a name = "line-124" > < / a > < span class = 'hs-keyword' > else< / span > < span class = 'hs-varid' > act< / span > < span class = 'hs-varid' > acc< / span > < span class = 'hs-varid' > path< / span >
< a name = "line-125" > < / a >
< a name = "line-126" > < / a > < a name = "actOnDirContents" > < / a > < span class = 'hs-definition' > actOnDirContents< / span > < span class = 'hs-keyglyph' > ::< / span > < span class = 'hs-conid' > RawFilePath< / span >
< a name = "line-127" > < / a > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-varid' > b< / span >
< a name = "line-128" > < / a > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-conid' > DirType< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-conid' > RawFilePath< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-varid' > b< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-conid' > IO< / span > < span class = 'hs-varid' > b< / span > < span class = 'hs-layout' > )< / span >
< a name = "line-129" > < / a > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-conid' > IO< / span > < span class = 'hs-varid' > b< / span >
< a name = "line-130" > < / a > < span class = 'hs-definition' > actOnDirContents< / span > < span class = 'hs-varid' > pathRelToTop< / span > < span class = 'hs-varid' > b< / span > < span class = 'hs-varid' > f< / span > < span class = 'hs-keyglyph' > =< / span >
< a name = "line-131" > < / a > < span class = 'hs-varid' > modifyIOError< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-varop' > `ioeSetFileName`< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-conid' > BS< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-varid' > unpack< / span > < span class = 'hs-varid' > pathRelToTop< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-varop' > .< / span >
< a name = "line-132" > < / a > < span class = 'hs-layout' > (< / span > < span class = 'hs-varop' > `ioeSetLocation`< / span > < span class = 'hs-str' > "findBSTypRel"< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-varop' > $< / span >
< a name = "line-133" > < / a > < span class = 'hs-varid' > bracket< / span >
< a name = "line-134" > < / a > < span class = 'hs-layout' > (< / span > < span class = 'hs-varid' > openDirStream< / span > < span class = 'hs-varid' > pathRelToTop< / span > < span class = 'hs-layout' > )< / span >
< a name = "line-135" > < / a > < span class = 'hs-conid' > Posix< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-varid' > closeDirStream< / span >
< a name = "line-136" > < / a > < span class = 'hs-layout' > (< / span > < span class = 'hs-keyglyph' > \< / span > < span class = 'hs-varid' > dirp< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-varid' > loop< / span > < span class = 'hs-varid' > dirp< / span > < span class = 'hs-varid' > b< / span > < span class = 'hs-layout' > )< / span >
< a name = "line-137" > < / a > < span class = 'hs-keyword' > where< / span >
< a name = "line-138" > < / a > < span class = 'hs-varid' > loop< / span > < span class = 'hs-varid' > dirp< / span > < span class = 'hs-varid' > b'< / span > < span class = 'hs-keyglyph' > =< / span > < span class = 'hs-keyword' > do< / span >
< a name = "line-139" > < / a > < span class = 'hs-layout' > (< / span > < span class = 'hs-varid' > typ< / span > < span class = 'hs-layout' > ,< / span > < span class = 'hs-varid' > e< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-keyglyph' > < -< / span > < span class = 'hs-varid' > readDirEnt< / span > < span class = 'hs-varid' > dirp< / span >
< a name = "line-140" > < / a > < span class = 'hs-keyword' > if< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-varid' > e< / span > < span class = 'hs-varop' > ==< / span > < span class = 'hs-str' > ""< / span > < span class = 'hs-layout' > )< / span >
< a name = "line-141" > < / a > < span class = 'hs-keyword' > then< / span > < span class = 'hs-varid' > return< / span > < span class = 'hs-varid' > b'< / span >
< a name = "line-142" > < / a > < span class = 'hs-keyword' > else< / span >
< a name = "line-143" > < / a > < span class = 'hs-keyword' > if< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-varid' > e< / span > < span class = 'hs-varop' > ==< / span > < span class = 'hs-str' > "."< / span > < span class = 'hs-varop' > ||< / span > < span class = 'hs-varid' > e< / span > < span class = 'hs-varop' > ==< / span > < span class = 'hs-str' > ".."< / span > < span class = 'hs-layout' > )< / span >
< a name = "line-144" > < / a > < span class = 'hs-keyword' > then< / span > < span class = 'hs-varid' > loop< / span > < span class = 'hs-varid' > dirp< / span > < span class = 'hs-varid' > b'< / span >
< a name = "line-145" > < / a > < span class = 'hs-keyword' > else< / span > < span class = 'hs-varid' > f< / span > < span class = 'hs-varid' > typ< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-varid' > pathRelToTop< / span > < span class = 'hs-varop' > < /> < / span > < span class = 'hs-varid' > e< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-varid' > b'< / span > < span class = 'hs-varop' > > > =< / span > < span class = 'hs-varid' > loop< / span > < span class = 'hs-varid' > dirp< / span >
2016-06-01 12:52:48 +00:00
< a name = "line-146" > < / a >
2016-06-05 14:22:57 +00:00
< a name = "line-147" > < / a >
< a name = "line-148" > < / a > < span class = 'hs-comment' > ----------------------------------------------------------< / span >
< a name = "line-149" > < / a > < span class = 'hs-comment' > -- dodgy stuff< / span >
< a name = "line-150" > < / a >
< a name = "line-151" > < / a > < a name = "CDir" > < / a > < span class = 'hs-keyword' > type< / span > < span class = 'hs-conid' > CDir< / span > < span class = 'hs-keyglyph' > =< / span > < span class = 'hs-conid' > ()< / span >
< a name = "line-152" > < / a > < a name = "CDirent" > < / a > < span class = 'hs-keyword' > type< / span > < span class = 'hs-conid' > CDirent< / span > < span class = 'hs-keyglyph' > =< / span > < span class = 'hs-conid' > ()< / span >
< a name = "line-153" > < / a >
< a name = "line-154" > < / a > < a name = "unpackDirStream" > < / a > < span class = 'hs-comment' > -- Posix doesn't export DirStream, so to re-use that type we need to use< / span >
< a name = "line-155" > < / a > < span class = 'hs-comment' > -- unsafeCoerce. It's just a newtype, so this is a legitimate usage.< / span >
< a name = "line-156" > < / a > < span class = 'hs-comment' > -- ugly trick.< / span >
< a name = "line-157" > < / a > < span class = 'hs-definition' > unpackDirStream< / span > < span class = 'hs-keyglyph' > ::< / span > < span class = 'hs-conid' > DirStream< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-conid' > Ptr< / span > < span class = 'hs-conid' > CDir< / span >
< a name = "line-158" > < / a > < span class = 'hs-definition' > unpackDirStream< / span > < span class = 'hs-keyglyph' > =< / span > < span class = 'hs-varid' > unsafeCoerce< / span >
< a name = "line-159" > < / a >
< a name = "line-160" > < / a > < a name = "packDirStream" > < / a > < span class = 'hs-definition' > packDirStream< / span > < span class = 'hs-keyglyph' > ::< / span > < span class = 'hs-conid' > Ptr< / span > < span class = 'hs-conid' > CDir< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-conid' > DirStream< / span >
< a name = "line-161" > < / a > < span class = 'hs-definition' > packDirStream< / span > < span class = 'hs-keyglyph' > =< / span > < span class = 'hs-varid' > unsafeCoerce< / span >
< a name = "line-162" > < / a >
< a name = "line-163" > < / a > < span class = 'hs-comment' > -- the __hscore_* functions are defined in the unix package. We can import them and let< / span >
< a name = "line-164" > < / a > < span class = 'hs-comment' > -- the linker figure it out.< / span >
< a name = "line-165" > < / a > < span class = 'hs-keyword' > foreign< / span > < span class = 'hs-keyword' > import< / span > < span class = 'hs-keyword' > ccall< / span > < span class = 'hs-keyword' > unsafe< / span > < span class = 'hs-str' > "__hscore_readdir"< / span >
< a name = "line-166" > < / a > < span class = 'hs-varid' > c_readdir< / span > < span class = 'hs-keyglyph' > ::< / span > < span class = 'hs-conid' > Ptr< / span > < span class = 'hs-conid' > CDir< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-conid' > Ptr< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-conid' > Ptr< / span > < span class = 'hs-conid' > CDirent< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-conid' > IO< / span > < span class = 'hs-conid' > CInt< / span >
< a name = "line-167" > < / a >
< a name = "line-168" > < / a > < span class = 'hs-keyword' > foreign< / span > < span class = 'hs-keyword' > import< / span > < span class = 'hs-keyword' > ccall< / span > < span class = 'hs-keyword' > unsafe< / span > < span class = 'hs-str' > "__hscore_free_dirent"< / span >
< a name = "line-169" > < / a > < span class = 'hs-varid' > c_freeDirEnt< / span > < span class = 'hs-keyglyph' > ::< / span > < span class = 'hs-conid' > Ptr< / span > < span class = 'hs-conid' > CDirent< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-conid' > IO< / span > < span class = 'hs-conid' > ()< / span >
< a name = "line-170" > < / a >
< a name = "line-171" > < / a > < span class = 'hs-keyword' > foreign< / span > < span class = 'hs-keyword' > import< / span > < span class = 'hs-keyword' > ccall< / span > < span class = 'hs-keyword' > unsafe< / span > < span class = 'hs-str' > "__hscore_d_name"< / span >
< a name = "line-172" > < / a > < span class = 'hs-varid' > c_name< / span > < span class = 'hs-keyglyph' > ::< / span > < span class = 'hs-conid' > Ptr< / span > < span class = 'hs-conid' > CDirent< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-conid' > IO< / span > < span class = 'hs-conid' > CString< / span >
< a name = "line-173" > < / a >
< a name = "line-174" > < / a > < span class = 'hs-keyword' > foreign< / span > < span class = 'hs-keyword' > import< / span > < span class = 'hs-keyword' > ccall< / span > < span class = 'hs-keyword' > unsafe< / span > < span class = 'hs-str' > "__posixdir_d_type"< / span >
< a name = "line-175" > < / a > < span class = 'hs-varid' > c_type< / span > < span class = 'hs-keyglyph' > ::< / span > < span class = 'hs-conid' > Ptr< / span > < span class = 'hs-conid' > CDirent< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-conid' > IO< / span > < span class = 'hs-conid' > DirType< / span >
< a name = "line-176" > < / a >
< a name = "line-177" > < / a > < span class = 'hs-keyword' > foreign< / span > < span class = 'hs-keyword' > import< / span > < span class = 'hs-keyword' > ccall< / span > < span class = 'hs-str' > "realpath"< / span >
< a name = "line-178" > < / a > < span class = 'hs-varid' > c_realpath< / span > < span class = 'hs-keyglyph' > ::< / span > < span class = 'hs-conid' > CString< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-conid' > CString< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-conid' > IO< / span > < span class = 'hs-conid' > CString< / span >
< a name = "line-179" > < / a >
< a name = "line-180" > < / a > < span class = 'hs-keyword' > foreign< / span > < span class = 'hs-keyword' > import< / span > < span class = 'hs-keyword' > ccall< / span > < span class = 'hs-keyword' > unsafe< / span > < span class = 'hs-str' > "fdopendir"< / span >
< a name = "line-181" > < / a > < span class = 'hs-varid' > c_fdopendir< / span > < span class = 'hs-keyglyph' > ::< / span > < span class = 'hs-conid' > Posix< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-conid' > Fd< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-conid' > IO< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-conid' > Ptr< / span > < span class = 'hs-conid' > ()< / span > < span class = 'hs-layout' > )< / span >
2016-06-01 12:52:48 +00:00
< a name = "line-182" > < / a >
2016-06-05 14:22:57 +00:00
< a name = "line-183" > < / a > < span class = 'hs-comment' > ----------------------------------------------------------< / span >
< a name = "line-184" > < / a > < span class = 'hs-comment' > -- less dodgy but still lower-level< / span >
< a name = "line-185" > < / a >
< a name = "line-186" > < / a >
< a name = "line-187" > < / a > < a name = "readDirEnt" > < / a > < span class = 'hs-definition' > readDirEnt< / span > < span class = 'hs-keyglyph' > ::< / span > < span class = 'hs-conid' > DirStream< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-conid' > IO< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-conid' > DirType< / span > < span class = 'hs-layout' > ,< / span > < span class = 'hs-conid' > RawFilePath< / span > < span class = 'hs-layout' > )< / span >
< a name = "line-188" > < / a > < span class = 'hs-definition' > readDirEnt< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-varid' > unpackDirStream< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-varid' > dirp< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-keyglyph' > =< / span >
< a name = "line-189" > < / a > < span class = 'hs-varid' > alloca< / span > < span class = 'hs-varop' > $< / span > < span class = 'hs-keyglyph' > \< / span > < span class = 'hs-varid' > ptr_dEnt< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-varid' > loop< / span > < span class = 'hs-varid' > ptr_dEnt< / span >
< a name = "line-190" > < / a > < span class = 'hs-keyword' > where< / span >
< a name = "line-191" > < / a > < span class = 'hs-varid' > loop< / span > < span class = 'hs-varid' > ptr_dEnt< / span > < span class = 'hs-keyglyph' > =< / span > < span class = 'hs-keyword' > do< / span >
< a name = "line-192" > < / a > < span class = 'hs-varid' > resetErrno< / span >
< a name = "line-193" > < / a > < span class = 'hs-varid' > r< / span > < span class = 'hs-keyglyph' > < -< / span > < span class = 'hs-varid' > c_readdir< / span > < span class = 'hs-varid' > dirp< / span > < span class = 'hs-varid' > ptr_dEnt< / span >
< a name = "line-194" > < / a > < span class = 'hs-keyword' > if< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-varid' > r< / span > < span class = 'hs-varop' > ==< / span > < span class = 'hs-num' > 0< / span > < span class = 'hs-layout' > )< / span >
< a name = "line-195" > < / a > < span class = 'hs-keyword' > then< / span > < span class = 'hs-keyword' > do< / span >
< a name = "line-196" > < / a > < span class = 'hs-varid' > dEnt< / span > < span class = 'hs-keyglyph' > < -< / span > < span class = 'hs-varid' > peek< / span > < span class = 'hs-varid' > ptr_dEnt< / span >
< a name = "line-197" > < / a > < span class = 'hs-keyword' > if< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-varid' > dEnt< / span > < span class = 'hs-varop' > ==< / span > < span class = 'hs-varid' > nullPtr< / span > < span class = 'hs-layout' > )< / span >
< a name = "line-198" > < / a > < span class = 'hs-keyword' > then< / span > < span class = 'hs-varid' > return< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-varid' > dtUnknown< / span > < span class = 'hs-layout' > ,< / span > < span class = 'hs-conid' > BS< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-varid' > empty< / span > < span class = 'hs-layout' > )< / span >
< a name = "line-199" > < / a > < span class = 'hs-keyword' > else< / span > < span class = 'hs-keyword' > do< / span >
< a name = "line-200" > < / a > < span class = 'hs-varid' > dName< / span > < span class = 'hs-keyglyph' > < -< / span > < span class = 'hs-varid' > c_name< / span > < span class = 'hs-varid' > dEnt< / span > < span class = 'hs-varop' > > > =< / span > < span class = 'hs-varid' > peekFilePath< / span >
< a name = "line-201" > < / a > < span class = 'hs-varid' > dType< / span > < span class = 'hs-keyglyph' > < -< / span > < span class = 'hs-varid' > c_type< / span > < span class = 'hs-varid' > dEnt< / span >
< a name = "line-202" > < / a > < span class = 'hs-varid' > c_freeDirEnt< / span > < span class = 'hs-varid' > dEnt< / span >
< a name = "line-203" > < / a > < span class = 'hs-varid' > return< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-varid' > dType< / span > < span class = 'hs-layout' > ,< / span > < span class = 'hs-varid' > dName< / span > < span class = 'hs-layout' > )< / span >
< a name = "line-204" > < / a > < span class = 'hs-keyword' > else< / span > < span class = 'hs-keyword' > do< / span >
< a name = "line-205" > < / a > < span class = 'hs-varid' > errno< / span > < span class = 'hs-keyglyph' > < -< / span > < span class = 'hs-varid' > getErrno< / span >
< a name = "line-206" > < / a > < span class = 'hs-keyword' > if< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-varid' > errno< / span > < span class = 'hs-varop' > ==< / span > < span class = 'hs-varid' > eINTR< / span > < span class = 'hs-layout' > )< / span >
< a name = "line-207" > < / a > < span class = 'hs-keyword' > then< / span > < span class = 'hs-varid' > loop< / span > < span class = 'hs-varid' > ptr_dEnt< / span >
< a name = "line-208" > < / a > < span class = 'hs-keyword' > else< / span > < span class = 'hs-keyword' > do< / span >
< a name = "line-209" > < / a > < span class = 'hs-keyword' > let< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-conid' > Errno< / span > < span class = 'hs-varid' > eo< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-keyglyph' > =< / span > < span class = 'hs-varid' > errno< / span >
< a name = "line-210" > < / a > < span class = 'hs-keyword' > if< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-varid' > eo< / span > < span class = 'hs-varop' > ==< / span > < span class = 'hs-num' > 0< / span > < span class = 'hs-layout' > )< / span >
< a name = "line-211" > < / a > < span class = 'hs-keyword' > then< / span > < span class = 'hs-varid' > return< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-varid' > dtUnknown< / span > < span class = 'hs-layout' > ,< / span > < span class = 'hs-conid' > BS< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-varid' > empty< / span > < span class = 'hs-layout' > )< / span >
< a name = "line-212" > < / a > < span class = 'hs-keyword' > else< / span > < span class = 'hs-varid' > throwErrno< / span > < span class = 'hs-str' > "readDirEnt"< / span >
< a name = "line-213" > < / a >
< a name = "line-214" > < / a >
< a name = "line-215" > < / a > < a name = "getDirectoryContents" > < / a > < span class = 'hs-comment' > -- |Gets all directory contents (not recursively).< / span >
< a name = "line-216" > < / a > < span class = 'hs-definition' > getDirectoryContents< / span > < span class = 'hs-keyglyph' > ::< / span > < span class = 'hs-conid' > RawFilePath< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-conid' > IO< / span > < span class = 'hs-keyglyph' > [< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-conid' > DirType< / span > < span class = 'hs-layout' > ,< / span > < span class = 'hs-conid' > RawFilePath< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-keyglyph' > ]< / span >
< a name = "line-217" > < / a > < span class = 'hs-definition' > getDirectoryContents< / span > < span class = 'hs-varid' > path< / span > < span class = 'hs-keyglyph' > =< / span >
< a name = "line-218" > < / a > < span class = 'hs-varid' > modifyIOError< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-varop' > `ioeSetFileName`< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-conid' > BS< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-varid' > unpack< / span > < span class = 'hs-varid' > path< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-varop' > .< / span >
< a name = "line-219" > < / a > < span class = 'hs-layout' > (< / span > < span class = 'hs-varop' > `ioeSetLocation`< / span > < span class = 'hs-str' > "System.Posix.Directory.Traversals.getDirectoryContents"< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-varop' > $< / span >
< a name = "line-220" > < / a > < span class = 'hs-varid' > bracket< / span >
< a name = "line-221" > < / a > < span class = 'hs-layout' > (< / span > < span class = 'hs-conid' > PosixBS< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-varid' > openDirStream< / span > < span class = 'hs-varid' > path< / span > < span class = 'hs-layout' > )< / span >
< a name = "line-222" > < / a > < span class = 'hs-conid' > PosixBS< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-varid' > closeDirStream< / span >
< a name = "line-223" > < / a > < span class = 'hs-sel' > _dirloop< / span >
< a name = "line-224" > < / a >
< a name = "line-225" > < / a >
< a name = "line-226" > < / a > < a name = "fdOpendir" > < / a > < span class = 'hs-comment' > -- |Binding to @fdopendir(3)@.< / span >
< a name = "line-227" > < / a > < span class = 'hs-definition' > fdOpendir< / span > < span class = 'hs-keyglyph' > ::< / span > < span class = 'hs-conid' > Posix< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-conid' > Fd< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-conid' > IO< / span > < span class = 'hs-conid' > DirStream< / span >
< a name = "line-228" > < / a > < span class = 'hs-definition' > fdOpendir< / span > < span class = 'hs-varid' > fd< / span > < span class = 'hs-keyglyph' > =< / span >
< a name = "line-229" > < / a > < span class = 'hs-varid' > packDirStream< / span > < span class = 'hs-varop' > < $> < / span > < span class = 'hs-varid' > throwErrnoIfNull< / span > < span class = 'hs-str' > "fdOpendir"< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-varid' > c_fdopendir< / span > < span class = 'hs-varid' > fd< / span > < span class = 'hs-layout' > )< / span >
< a name = "line-230" > < / a >
< a name = "line-231" > < / a >
< a name = "line-232" > < / a > < a name = "getDirectoryContents'" > < / a > < span class = 'hs-comment' > -- |Like `getDirectoryContents` except for a file descriptor.< / span >
< a name = "line-233" > < / a > < span class = 'hs-comment' > --< / span >
< a name = "line-234" > < / a > < span class = 'hs-comment' > -- To avoid complicated error checks, the file descriptor is< / span >
< a name = "line-235" > < / a > < span class = 'hs-comment' > -- __always__ closed, even if `fdOpendir` fails. Usually, this< / span >
< a name = "line-236" > < / a > < span class = 'hs-comment' > -- only happens on successful `fdOpendir` and after the directory< / span >
< a name = "line-237" > < / a > < span class = 'hs-comment' > -- stream is closed. Also see the manpage of @fdopendir(3)@ for< / span >
< a name = "line-238" > < / a > < span class = 'hs-comment' > -- more details.< / span >
< a name = "line-239" > < / a > < span class = 'hs-definition' > getDirectoryContents'< / span > < span class = 'hs-keyglyph' > ::< / span > < span class = 'hs-conid' > Posix< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-conid' > Fd< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-conid' > IO< / span > < span class = 'hs-keyglyph' > [< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-conid' > DirType< / span > < span class = 'hs-layout' > ,< / span > < span class = 'hs-conid' > RawFilePath< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-keyglyph' > ]< / span >
< a name = "line-240" > < / a > < span class = 'hs-definition' > getDirectoryContents'< / span > < span class = 'hs-varid' > fd< / span > < span class = 'hs-keyglyph' > =< / span > < span class = 'hs-keyword' > do< / span >
< a name = "line-241" > < / a > < span class = 'hs-varid' > dirstream< / span > < span class = 'hs-keyglyph' > < -< / span > < span class = 'hs-varid' > fdOpendir< / span > < span class = 'hs-varid' > fd< / span > < span class = 'hs-varop' > `catchIOError`< / 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-242" > < / a > < span class = 'hs-varid' > closeFd< / span > < span class = 'hs-varid' > fd< / span >
< a name = "line-243" > < / a > < span class = 'hs-varid' > ioError< / span > < span class = 'hs-varid' > e< / span >
< a name = "line-244" > < / a > < span class = 'hs-comment' > -- closeDirStream closes the filedescriptor< / span >
< a name = "line-245" > < / a > < span class = 'hs-varid' > finally< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-sel' > _dirloop< / span > < span class = 'hs-varid' > dirstream< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-conid' > PosixBS< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-varid' > closeDirStream< / span > < span class = 'hs-varid' > dirstream< / span > < span class = 'hs-layout' > )< / span >
< a name = "line-246" > < / a >
< a name = "line-247" > < / a >
< a name = "line-248" > < / a > < span class = 'hs-sel' > _dirloop< / span > < span class = 'hs-keyglyph' > ::< / span > < span class = 'hs-conid' > DirStream< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-conid' > IO< / span > < span class = 'hs-keyglyph' > [< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-conid' > DirType< / span > < span class = 'hs-layout' > ,< / span > < span class = 'hs-conid' > RawFilePath< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-keyglyph' > ]< / span >
< a name = "line-249" > < / a > < span class = 'hs-comment' > {-# INLINE _dirloop #-}< / span >
< a name = "line-250" > < / a > < span class = 'hs-sel' > _dirloop< / span > < span class = 'hs-varid' > dirp< / span > < span class = 'hs-keyglyph' > =< / span > < span class = 'hs-keyword' > do< / span >
< a name = "line-251" > < / a > < span class = 'hs-varid' > t< / span > < span class = 'hs-keyglyph' > @< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-sel' > _typ< / span > < span class = 'hs-layout' > ,< / span > < span class = 'hs-varid' > e< / span > < span class = 'hs-layout' > )< / span > < span class = 'hs-keyglyph' > < -< / span > < span class = 'hs-varid' > readDirEnt< / span > < span class = 'hs-varid' > dirp< / span >
< a name = "line-252" > < / a > < span class = 'hs-keyword' > if< / span > < span class = 'hs-conid' > BS< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-varid' > null< / span > < span class = 'hs-varid' > e< / span > < span class = 'hs-keyword' > then< / span > < span class = 'hs-varid' > return< / span > < span class = 'hs-conid' > []< / span > < span class = 'hs-keyword' > else< / span > < span class = 'hs-keyword' > do< / span >
< a name = "line-253" > < / a > < span class = 'hs-varid' > es< / span > < span class = 'hs-keyglyph' > < -< / span > < span class = 'hs-sel' > _dirloop< / span > < span class = 'hs-varid' > dirp< / span >
< a name = "line-254" > < / a > < span class = 'hs-varid' > return< / span > < span class = 'hs-layout' > (< / span > < span class = 'hs-varid' > t< / span > < span class = 'hs-conop' > :< / span > < span class = 'hs-varid' > es< / span > < span class = 'hs-layout' > )< / span >
< a name = "line-255" > < / a >
< a name = "line-256" > < / a >
< a name = "line-257" > < / a > < a name = "realpath" > < / a > < span class = 'hs-comment' > -- | return the canonicalized absolute pathname< / span >
< a name = "line-258" > < / a > < span class = 'hs-comment' > --< / span >
< a name = "line-259" > < / a > < span class = 'hs-comment' > -- like canonicalizePath, but uses @realpath(3)@< / span >
< a name = "line-260" > < / a > < span class = 'hs-definition' > realpath< / span > < span class = 'hs-keyglyph' > ::< / span > < span class = 'hs-conid' > RawFilePath< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-conid' > IO< / span > < span class = 'hs-conid' > RawFilePath< / span >
< a name = "line-261" > < / a > < span class = 'hs-definition' > realpath< / span > < span class = 'hs-varid' > inp< / span > < span class = 'hs-keyglyph' > =< / span >
< a name = "line-262" > < / a > < span class = 'hs-varid' > allocaBytes< / span > < span class = 'hs-varid' > pathMax< / span > < span class = 'hs-varop' > $< / span > < span class = 'hs-keyglyph' > \< / span > < span class = 'hs-varid' > tmp< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-keyword' > do< / span >
< a name = "line-263" > < / a > < span class = 'hs-varid' > void< / span > < span class = 'hs-varop' > $< / span > < span class = 'hs-conid' > BS< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-varid' > useAsCString< / span > < span class = 'hs-varid' > inp< / span > < span class = 'hs-varop' > $< / span > < span class = 'hs-keyglyph' > \< / span > < span class = 'hs-varid' > cstr< / span > < span class = 'hs-keyglyph' > -> < / span > < span class = 'hs-varid' > throwErrnoIfNull< / span > < span class = 'hs-str' > "realpath"< / span > < span class = 'hs-varop' > $< / span > < span class = 'hs-varid' > c_realpath< / span > < span class = 'hs-varid' > cstr< / span > < span class = 'hs-varid' > tmp< / span >
< a name = "line-264" > < / a > < span class = 'hs-conid' > BS< / span > < span class = 'hs-varop' > .< / span > < span class = 'hs-varid' > packCString< / span > < span class = 'hs-varid' > tmp< / span >
2016-06-01 12:52:48 +00:00
< / pre > < / body >
< / html >