Skip to content

Commit

Permalink
io.directories: delete directory-tree-files.
Browse files Browse the repository at this point in the history
recursive-directory-files is strictly superior.
  • Loading branch information
mrjbq7 committed Feb 26, 2021
1 parent fd42dc0 commit 122de83
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 56 deletions.
12 changes: 0 additions & 12 deletions basis/io/directories/directories-docs.factor
Expand Up @@ -313,13 +313,6 @@ ARTICLE: "io.directories.search" "Searching directories"
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" } }
Expand Down Expand Up @@ -349,11 +342,6 @@ ARTICLE: "io.directories.hierarchy" "Directory hierarchy manipulation"
{ "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:"
Expand Down
18 changes: 0 additions & 18 deletions basis/io/directories/directories-tests.factor
Expand Up @@ -292,21 +292,3 @@ system tools.test ;
] 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
17 changes: 0 additions & 17 deletions basis/io/directories/directories.factor
Expand Up @@ -248,23 +248,6 @@ M: object copy-file
: 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 Down
6 changes: 4 additions & 2 deletions basis/vocabs/metadata/resources/resources.factor
Expand Up @@ -19,8 +19,10 @@ PRIVATE>

: 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 ;

Expand Down
13 changes: 6 additions & 7 deletions extra/codebook/codebook.factor
Expand Up @@ -50,13 +50,12 @@ TUPLE: code-file
} 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 )
{
Expand Down

0 comments on commit 122de83

Please sign in to comment.