globs: rename glob-directory to glob.

locals-and-roots
John Benediktsson 2016-04-06 14:04:21 -07:00
parent a5f117c88f
commit 1234eb72e2
2 changed files with 20 additions and 20 deletions

View File

@ -75,15 +75,15 @@ tools.test ;
"a/e/g" make-directory "a/e/g" make-directory
"a/e/g/e" touch-file "a/e/g/e" touch-file
"**" glob-directory natural-sort "**" glob natural-sort
"**/" glob-directory natural-sort "**/" glob natural-sort
"**/*" glob-directory natural-sort "**/*" glob natural-sort
"**/**" glob-directory natural-sort "**/**" glob natural-sort
"**/b" glob-directory natural-sort "**/b" glob natural-sort
"**/e" glob-directory natural-sort "**/e" glob natural-sort
! "**//e" glob-directory natural-sort ! "**//e" glob natural-sort
! "**/**/e" glob-directory natural-sort ! "**/**/e" glob natural-sort
"**/e/**" glob-directory natural-sort "**/e/**" glob natural-sort
"a/**" glob-directory natural-sort "a/**" glob natural-sort
] with-test-directory ] with-test-directory
] unit-test ] unit-test

View File

@ -60,16 +60,16 @@ Main = Concatenation End
! TODO: make case-fold an option, off by default ! TODO: make case-fold an option, off by default
! TODO: maybe make case-fold an option on regexp ! TODO: maybe make case-fold an option on regexp
DEFER: glob-directory% DEFER: glob%
: glob-entries ( path -- entries ) : glob-entries ( path -- entries )
directory-entries [ name>> "." head? ] reject ; directory-entries [ name>> "." head? ] reject ;
: ?glob-directory% ( root remaining entry -- ) : ?glob% ( root remaining entry -- )
over empty? [ over empty? [
2drop , 2drop ,
] [ ] [
directory? [ glob-directory% ] [ 2drop ] if directory? [ glob% ] [ 2drop ] if
] if ; ] if ;
:: glob-wildcard% ( root globs -- ) :: glob-wildcard% ( root globs -- )
@ -94,7 +94,7 @@ DEFER: glob-directory%
dup , dup ,
] [ ] [
entry directory? [ entry directory? [
dupd glob-directory% dupd glob%
] [ ] [
drop drop
] if ] if
@ -104,7 +104,7 @@ DEFER: glob-directory%
} cond } cond
{ [ entry directory? ] [ next-glob ] } 0&& [ { [ entry directory? ] [ next-glob ] } 0&& [
globs glob-directory% globs glob%
] [ ] [
drop drop
] if ] if
@ -116,7 +116,7 @@ DEFER: glob-directory%
root glob-entries [| entry | root glob-entries [| entry |
entry name>> >case-fold glob matches? [ entry name>> >case-fold glob matches? [
root entry name>> append-path root entry name>> append-path
remaining entry ?glob-directory% remaining entry ?glob%
] when ] when
] each ; ] each ;
@ -124,12 +124,12 @@ DEFER: glob-directory%
globs unclip :> ( remaining glob ) globs unclip :> ( remaining glob )
root glob append-path dup exists? [ root glob append-path dup exists? [
remaining over file-info ?glob-directory% remaining over file-info ?glob%
] [ ] [
drop drop
] if ; ] if ;
: glob-directory% ( root globs -- ) : glob% ( root globs -- )
dup ?first { dup ?first {
{ f [ 2drop ] } { f [ 2drop ] }
{ "**" [ glob-wildcard% ] } { "**" [ glob-wildcard% ] }
@ -155,5 +155,5 @@ DEFER: glob-directory%
PRIVATE> PRIVATE>
: glob-directory ( glob -- files ) : glob ( glob -- files )
glob-path [ glob-directory% ] { } make ; glob-path [ glob% ] { } make ;