Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(799)

Side by Side Diff: pkg/glob/lib/glob.dart

Issue 607963002: Fix glob list on Windows. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/glob/lib/src/ast.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library glob; 5 library glob;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:io'; 8 import 'dart:io';
9 9
10 import 'package:path/path.dart' as p; 10 import 'package:path/path.dart' as p;
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 bool matches(String path) => matchAsPrefix(path) != null; 148 bool matches(String path) => matchAsPrefix(path) != null;
149 149
150 Match matchAsPrefix(String path, [int start = 0]) { 150 Match matchAsPrefix(String path, [int start = 0]) {
151 // Globs are like anchored RegExps in that they only match entire paths, so 151 // Globs are like anchored RegExps in that they only match entire paths, so
152 // if the match starts anywhere after the first character it can't succeed. 152 // if the match starts anywhere after the first character it can't succeed.
153 if (start != 0) return null; 153 if (start != 0) return null;
154 154
155 if (_patternCanMatchAbsolute && 155 if (_patternCanMatchAbsolute &&
156 (_contextIsAbsolute || context.isAbsolute(path))) { 156 (_contextIsAbsolute || context.isAbsolute(path))) {
157 var absolutePath = context.normalize(context.absolute(path)); 157 var absolutePath = context.normalize(context.absolute(path));
158 if (_ast.matches(_toPosixPath(absolutePath))) { 158 if (_ast.matches(toPosixPath(context, absolutePath))) {
159 return new GlobMatch(path, this); 159 return new GlobMatch(path, this);
160 } 160 }
161 } 161 }
162 162
163 if (_patternCanMatchRelative) { 163 if (_patternCanMatchRelative) {
164 var relativePath = context.relative(path); 164 var relativePath = context.relative(path);
165 if (_ast.matches(_toPosixPath(relativePath))) { 165 if (_ast.matches(toPosixPath(context, relativePath))) {
166 return new GlobMatch(path, this); 166 return new GlobMatch(path, this);
167 } 167 }
168 } 168 }
169 169
170 return null; 170 return null;
171 } 171 }
172 172
173 /// Returns [path] converted to the POSIX format that globs match against.
174 String _toPosixPath(String path) {
175 if (context.style == p.Style.windows) return path.replaceAll('\\', '/');
176 if (context.style == p.Style.url) return Uri.decodeFull(path);
177 return path;
178 }
179
180 Iterable<Match> allMatches(String path, [int start = 0]) { 173 Iterable<Match> allMatches(String path, [int start = 0]) {
181 var match = matchAsPrefix(path, start); 174 var match = matchAsPrefix(path, start);
182 return match == null ? [] : [match]; 175 return match == null ? [] : [match];
183 } 176 }
184 177
185 String toString() => pattern; 178 String toString() => pattern;
186 } 179 }
OLDNEW
« no previous file with comments | « no previous file | pkg/glob/lib/src/ast.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698