-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Port of Find function of FileManip lib for use on windows systems -- -- A Haskell library for working with files and directories. Includes -- code for pattern matching, finding files, modifying file contents, and -- more. @package FileManipCompat @version 0.13 module System.FilePath.FindCompat -- | Information collected during the traversal of a directory. data FileInfo FileInfo :: FilePath -> Int -> FileStatus -> FileInfo -- | file path infoPath :: FileInfo -> FilePath -- | current recursion depth infoDepth :: FileInfo -> Int -- | status of file infoStatus :: FileInfo -> FileStatus data FileType BlockDevice :: FileType CharacterDevice :: FileType NamedPipe :: FileType RegularFile :: FileType Directory :: FileType SymbolicLink :: FileType Socket :: FileType Unknown :: FileType -- | Return the type of file currently being visited. -- -- Example: -- --
-- fileType ==? RegularFile --fileType :: FindClause FileType -- | Return the type of a file. This is much more useful for case analysis -- than the usual functions on FileStatus values. statusType :: FileStatus -> FileType -- | Construct a FileInfo value. mkFI :: FilePath -> Int -> FileStatus -> FileInfo -- | Monadic container for file information, allowing for clean -- construction of combinators. Wraps the State monad, but doesn't -- allow get or put. newtype FindClause a FC :: State FileInfo a -> FindClause a runFC :: FindClause a -> State FileInfo a -- | 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 --evalClause :: FindClause a -> FileInfo -> a evalFI :: FindClause a -> FilePath -> Int -> FileStatus -> a mkFindClause :: (FileInfo -> (a, FileInfo)) -> FindClause a -- | Return the current FileInfo. fileInfo :: FindClause FileInfo -- | Return the FileStatus for the current file. fileStatus :: FindClause FileStatus type FilterPredicate = FindClause Bool type RecursionPredicate = FindClause Bool -- | List the files in the given directory, sorted, and without "." or -- "..". getDirContents :: FilePath -> IO [FilePath] -- | 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. findWithHandler :: (FilePath -> SomeException -> IO [FilePath]) -> RecursionPredicate -> FilterPredicate -> FilePath -> IO [FilePath] -- | 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. find :: RecursionPredicate -> FilterPredicate -> FilePath -> IO [FilePath] -- | Unconditionally return True. always :: FindClause Bool -- | Return the name of the file being visited. filePath :: FindClause FilePath -- | 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. liftOp :: (Monad m) => (a -> b -> c) -> m a -> b -> m c (==?) :: (Eq a) => FindClause a -> a -> FindClause Bool (/=?) :: (Eq a) => FindClause a -> a -> FindClause Bool (>?) :: (Ord a) => FindClause a -> a -> FindClause Bool () :: (Ord a) => FindClause a -> a -> FindClause Bool (>=?) :: (Ord a) => FindClause a -> a -> FindClause Bool (<=?) :: (Ord a) => FindClause a -> a -> FindClause Bool -- | This operator is useful to check if bits are set in a -- T.FileMode. (.&.?) :: (Bits a) => FindClause a -> a -> FindClause a (&&?) :: FindClause Bool -> FindClause Bool -> FindClause Bool (||?) :: FindClause Bool -> FindClause Bool -> FindClause Bool instance Functor FindClause instance Monad FindClause instance Eq FileType instance Ord FileType instance Show FileType instance Eq FileInfo instance Eq FileStatus