! Copyright (C) 2007, 2009 Slava Pestov, Daniel Ehrenberg.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors arrays combinators combinators.short-circuit
-io.directories io.files io.files.info io.pathnames kernel locals
+io.directories io.files io.files.info io.pathnames kernel
make peg.ebnf regexp regexp.combinators sequences strings system
-unicode ;
+unicode multiline ;
IN: globs
: not-path-separator ( -- sep )
- os windows? R/ [^\\/\\]/ R/ [^\\/]/ ? ; foldable
+ os windows? R/ [^\/\\]/ R/ [^\/]/ ? ; foldable
: wild-path-separator ( -- sep )
- os windows? R/ [^\\/\\][\\/\\]|[^\\/\\]/ R/ [^\\/][\\/]|[^\\/]/ ? ; foldable
+ os windows? R/ [^\/\\][\/\\]|[^\/\\]/ R/ [^\/][\/]|[^\/]/ ? ; foldable
-EBNF: <glob>
+EBNF: <glob> [=[
Character = "\\" .:c => [[ c 1string <literal> ]]
| !(","|"}") . => [[ 1string <literal> ]]
Main = Concatenation End
-;EBNF
+]=]
: glob-matches? ( input glob -- ? )
[ >case-fold ] bi@ <glob> matches? ;
:: glob-literal% ( root globs -- )
globs unclip :> ( remaining glob )
- root glob append-path dup exists? [
+ root glob append-path dup file-exists? [
remaining over file-info ?glob%
] [
drop