Index: lib/glob.dart |
diff --git a/lib/glob.dart b/lib/glob.dart |
index 2d2a83f6a9b3a0d4e0b5034d18c19f476e7b2e55..2a424c131d89c304b87c4a0c0f61fe0807b8c1d1 100644 |
--- a/lib/glob.dart |
+++ b/lib/glob.dart |
@@ -45,6 +45,9 @@ class Glob implements Pattern { |
/// contained within a directory that matches. |
final bool recursive; |
+ /// Whether the glob matches paths case-sensitively. |
+ bool get caseSensitive => _ast.caseSensitive; |
+ |
/// The parsed AST of the glob. |
final AstNode _ast; |
@@ -89,19 +92,22 @@ class Glob implements Pattern { |
/// |
/// If [recursive] is true, this glob will match and list not only the files |
/// and directories it explicitly lists, but anything beneath those as well. |
Bob Nystrom
2015/12/02 01:01:43
"lists" -> "matches"?
nweiz
2015/12/02 01:33:01
Done.
|
- Glob(String pattern, {p.Context context, bool recursive: false}) |
- : this._( |
- pattern, |
- context == null ? p.context : context, |
- recursive); |
- |
- // Internal constructor used to fake local variables for [context] and [ast]. |
- Glob._(String pattern, p.Context context, bool recursive) |
- : pattern = pattern, |
- context = context, |
- recursive = recursive, |
- _ast = new Parser(pattern + (recursive ? "{,/**}" : ""), context) |
- .parse(); |
+ /// |
+ /// If [caseSensitive] is true, this glob will match and list only files whose |
Bob Nystrom
2015/12/02 01:01:43
"will match" -> "matches", etc.
nweiz
2015/12/02 01:33:01
Done.
|
+ /// case matches that of the characters in the glob. Otherwise, it will match |
+ /// regardless of case. This defaults to `false` when [context] is Windows and |
+ /// `true` otherwise. |
+ factory Glob(String pattern, {p.Context context, bool recursive: false, |
+ bool caseSensitive}) { |
+ context ??= p.context; |
+ caseSensitive ??= context.style == p.Style.windows ? false : true; |
+ if (recursive) pattern += "{,/**}"; |
+ |
+ var parser = new Parser(pattern, context, caseSensitive: caseSensitive); |
+ return new Glob._(pattern, context, parser.parse(), recursive); |
+ } |
+ |
+ Glob._(this.pattern, this.context, this._ast, this.recursive); |
/// Lists all [FileSystemEntity]s beneath [root] that match the glob. |
/// |