FileManipCompat-0.13: Port of Find function of FileManip lib for use on windows systems

System.FilePath.FindCompat

Synopsis

Documentation

data FileInfo Source

Information collected during the traversal of a directory.

Constructors

FileInfo 

Fields

infoPath :: FilePath

file path

infoDepth :: Int

current recursion depth

infoStatus :: FileStatus

status of file

Instances

fileType :: FindClause FileTypeSource

Return the type of file currently being visited.

Example:

 fileType ==? RegularFile

statusType :: FileStatus -> FileTypeSource

Return the type of a file. This is much more useful for case analysis than the usual functions on FileStatus values.

mkFI :: FilePath -> Int -> FileStatus -> FileInfoSource

Construct a FileInfo value.

newtype FindClause a Source

Monadic container for file information, allowing for clean construction of combinators. Wraps the State monad, but doesn't allow get or put.

Constructors

FC 

Fields

runFC :: State FileInfo a
 

evalClause :: FindClause a -> FileInfo -> aSource

Run the given FindClause on the given FileInfo and return its result. This can be useful if you are writing a function to pass to fold.

Example:

 myFoldFunc :: a -> FileInfo -> a
 myFoldFunc a i = let useThisFile = evalClause (fileName ==? "foo") i
                  in if useThisFile
                     then fiddleWith a
                     else a

fileStatus :: FindClause FileStatusSource

Return the FileStatus for the current file.

getDirContents :: FilePath -> IO [FilePath]Source

List the files in the given directory, sorted, and without "." or "..".

findWithHandlerSource

Arguments

:: (FilePath -> SomeException -> IO [FilePath])

error handler

-> RecursionPredicate

control recursion into subdirectories

-> FilterPredicate

decide whether a file appears in the result

-> FilePath

directory to start searching

-> IO [FilePath]

files that matched the FilterPredicate

Search a directory recursively, with recursion controlled by a RecursionPredicate. Lazily return a sorted list of all files matching the given FilterPredicate. Any errors that occur are dealt with by the given handler.

findSource

Arguments

:: RecursionPredicate

control recursion into subdirectories

-> FilterPredicate

decide whether a file appears in the result

-> FilePath

directory to start searching

-> IO [FilePath]

files that matched the FilterPredicate

Search a directory recursively, with recursion controlled by a RecursionPredicate. Lazily return a sorted list of all files matching the given FilterPredicate. Any errors that occur are ignored, with warnings printed to stderr.

always :: FindClause BoolSource

Unconditionally return True.

filePath :: FindClause FilePathSource

Return the name of the file being visited.

liftOp :: Monad m => (a -> b -> c) -> m a -> b -> m cSource

Lift a binary operator into the FindClause monad, so that it becomes a combinator. The left hand side of the combinator should be a FindClause a, while the right remains a normal value of type a.

These are lifted versions of the most commonly used binary operators. They have the same fixities and associativities as their unlifted counterparts. They are lifted using liftOp, like so:

(==?) = liftOp (==)

(.&.?) :: Bits a => FindClause a -> a -> FindClause aSource

This operator is useful to check if bits are set in a T.FileMode.