diff --git a/README.md b/README.md index 30b5ca3..73f617c 100644 --- a/README.md +++ b/README.md @@ -19,9 +19,11 @@ Glob is implemented to have both a functional form and an object-oriented form. glob"a/?/c" + Attempting to creat a GlobMatch object from a string with a leading `/` or the empty string is an error. + 2. A string, which will be converted into a GlobMatch expression: - "a/?/c" # equivalent to 1, above + "a/?/c" # equivalent to 1, above, except that a leading `/` is allowed here 3. A vector of strings and/or objects which implement `ismatch`, including `Regex` and `Glob.FilenameMatch` objects @@ -32,8 +34,6 @@ Glob is implemented to have both a functional form and an object-oriented form. 4. A trailing `/` (or equivalently, a trailing empty string in the vector) will cause glob to only match directories - 5. Attempting to creat a GlobMatch object from a string with a leading `/` or the empty string is an error - * `readdir(pattern::GlobMatch, [directory::String])` :: * alias for `glob()` diff --git a/src/Glob.jl b/src/Glob.jl index bb83e75..b9e2ecd 100644 --- a/src/Glob.jl +++ b/src/Glob.jl @@ -343,6 +343,10 @@ function glob(pattern, prefix::String="") return matches end +function glob(pattern::String) + first(pattern) == '/' ? glob(pattern[2:end], "/") : glob(pattern, "") +end + function _glob!(matches, pat::String) i = 1 last = length(matches)