Hi, I was missing a simple entry point like find but which also returns the FileInfo.
-- | Search a directory recursively, with recursion controlled by a
-- 'RecursionPredicate'. Lazily return a unsorted list of all files
-- matching the given 'FilterPredicate'. Any errors that occur are
-- ignored, with warnings printed to 'stderr'.
findWithInfo
:: RecursionPredicate -- ^ Control recursion into subdirectories.
-> FilterPredicate -- ^ Decide whether a file appears in the result.
-> FilePath -- ^ Directory to start searching.
-> IO [FileInfo] -- ^ Files that matched the 'FilterPredicate'.
findWithInfo recurse filt dir = fold recurse act [] dir
where
-- Add file to list front when it matches the filter
act :: [FileInfo] -> FileInfo -> [FileInfo]
act fs f
| evalClause filt f = f:fs
| otherwise = fs
This one could be useful, as it allows e.g. sorting the result by other criteria than the file name. The result of find can be obtained from this one by projecting the infoPath.
Hi, I was missing a simple entry point like
find
but which also returns theFileInfo
.This one could be useful, as it allows e.g. sorting the result by other criteria than the file name. The result of
find
can be obtained from this one by projecting theinfoPath
.