io.directories: directory-tree-files should include the directories too, not just their contents

db4
Joe Groff 2010-02-13 13:57:58 -08:00
parent 72de727d0e
commit 1632fa6448
3 changed files with 12 additions and 3 deletions

View File

@ -48,7 +48,7 @@ HELP: directory-files
HELP: directory-tree-files HELP: directory-tree-files
{ $values { "path" "a pathname string" } { "seq" "a sequence of filenames" } } { $values { "path" "a pathname string" } { "seq" "a sequence of filenames" } }
{ $description "Outputs a sequence of all non-directory files inside the directory named by " { $snippet "path" } " and its subdirectories." } ; { $description "Outputs a sequence of all files and subdirectories inside the directory named by " { $snippet "path" } " or recursively inside its subdirectories." } ;
HELP: with-directory-files HELP: with-directory-files
{ $values { "path" "a pathname string" } { "quot" quotation } } { $values { "path" "a pathname string" } { "quot" quotation } }

View File

@ -28,6 +28,12 @@ IN: io.directories.tests
] with-directory ] with-directory
] unit-test ] unit-test
[ { "classes/tuple" } ] [
"resource:core" [
"." directory-tree-files [ "classes/tuple" = ] filter
] with-directory
] unit-test
[ { "classes/tuple/tuple.factor" } ] [ [ { "classes/tuple/tuple.factor" } ] [
"resource:core" [ "resource:core" [
[ "classes/tuple/tuple.factor" = ] filter [ "classes/tuple/tuple.factor" = ] filter

View File

@ -45,8 +45,11 @@ HOOK: (directory-entries) os ( path -- seq )
dup directory-entries dup directory-entries
[ [
dup type>> +directory+ = dup type>> +directory+ =
[ name>> [ append-path directory-tree-files ] [ [ prepend-path ] curry map ] bi ] [ name>>
[ nip name>> 1array ] if [ append-path directory-tree-files ]
[ [ prepend-path ] curry map ]
[ prefix ] tri
] [ nip name>> 1array ] if
] with map concat ; ] with map concat ;
: with-directory-entries ( path quot -- ) : with-directory-entries ( path quot -- )