HELP: find-all-files
{ $values
- { "path" "a pathname string" } { "bfs?" "a boolean, breadth-first or depth-first" } { "quot" quotation }
+ { "path" "a pathname string" } { "quot" quotation }
{ "paths/f" "a sequence of pathname strings or f" }
}
{ $description "Finds all files in the input directory matching the predicate quotation in a breadth-first or depth-first traversal." } ;
[ t ] [
[
10 [ "io.paths.test" "gogogo" make-unique-file ] replicate
- current-temporary-directory get t [ ] find-all-files
+ current-temporary-directory get [ ] find-all-files
] with-unique-directory drop [ natural-sort ] bi@ =
] unit-test
[ keep and ] curry iterate-directory
] [ drop f ] recover ; inline
-: find-all-files ( path bfs? quot: ( obj -- ? ) -- paths/f )
+: find-all-files ( path quot: ( obj -- ? ) -- paths/f )
+ f swap
'[
_ _ _ [ <directory-iterator> ] dip
pusher [ [ f ] compose iterate-directory drop ] dip
: program-files-directories ( -- array )
program-files program-files-x86 2array harvest ; inline
-: find-in-program-files ( base-directory bfs? quot -- path )
- [
+: find-in-program-files ( base-directory quot -- path )
+ t swap [
[ program-files-directories ] dip '[ _ append-path ] map
] 2dip find-in-directories ; inline