recursive-directory-files is strictly superior.
find-files-by-extension
find-files-by-extensions
} ;
-HELP: directory-tree-files
-{ $values { "path" "a pathname string" } { "seq" "a sequence of filenames" } }
-{ $description "Outputs a sequence of all files and subdirectories inside the directory named by " { $snippet "path" } " or recursively inside its subdirectories." } ;
-
-HELP: with-directory-tree-files
-{ $values { "path" "a pathname string" } { "quot" quotation } }
-{ $description "Calls the quotation with the recursive directory file names on the stack and with the directory set as the " { $link current-directory } ". Restores the current directory after the quotation is called." } ;
HELP: delete-tree
{ $values { "path" "a pathname string" } }
{ "Words named " { $snippet { $emphasis "operation" } "-file" } " which work on regular files only." }
{ "Words named " { $snippet { $emphasis "operation" } "-tree" } " works on directory trees recursively, and also accepts regular files." }
}
-"Listing directory trees recursively:"
-{ $subsections
- directory-tree-files
- with-directory-tree-files
-}
"Deleting directory trees recursively:"
{ $subsections delete-tree }
"Copying directory trees recursively:"
] with-variable
] with-test-directory
] unit-test
-
-{ { "classes/tuple/tuple.factor" } } [
- "resource:core" [
- "." directory-tree-files [ "classes/tuple/tuple.factor" = ] filter
- ] with-directory
-] unit-test
-
-{ { "classes/tuple" } } [
- "resource:core" [
- "." directory-tree-files [ "classes/tuple" = ] filter
- ] with-directory
-] unit-test
-
-{ { "classes/tuple/tuple.factor" } } [
- "resource:core" [
- [ "classes/tuple/tuple.factor" = ] filter
- ] with-directory-tree-files
-] unit-test
: copy-files-into ( files to -- )
'[ _ copy-file-into ] each ;
-<PRIVATE
-
-: directory-tree-files% ( path prefix -- )
- [ dup directory-entries ] dip '[
- [ name>> [ append-path ] [ _ prepend-path ] bi ]
- [ directory? ] bi over ,
- [ directory-tree-files% ] [ 2drop ] if
- ] with each ;
-
-PRIVATE>
-
-: directory-tree-files ( path -- seq )
- [ "" directory-tree-files% ] { } make ;
-
-: with-directory-tree-files ( path quot -- )
- '[ "" directory-tree-files @ ] with-directory ; inline
-
: delete-tree ( path -- )
dup link-info directory? [
[ [ [ delete-tree ] each ] with-directory-files ]
: expand-resource ( resource-path -- filenames )
dup dup file-info directory? [
- dup directory-tree-files [ append-path ] with map
- ] [ drop { } ] if swap prefix ;
+ recursive-directory-files
+ ] [
+ drop { }
+ ] if swap prefix ;
ERROR: resource-missing pattern ;
} 1&& ;
: code-files ( dir -- files )
- '[
- [ include-file-name? ] filter [
- dup detect-file dup binary?
- [ f ] [ 2dup dupd first-line find-mode ] if
- code-file boa
- ] map [ mode>> ] filter [ name>> ] sort-with
- ] with-directory-tree-files ;
+ recursive-directory-files
+ [ include-file-name? ] filter [
+ dup detect-file dup binary?
+ [ f ] [ 2dup dupd first-line find-mode ] if
+ code-file boa
+ ] map [ mode>> ] filter [ name>> ] sort-with ;
: html-name-char ( char -- str )
{