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

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

Issue 549633002: Add support for listing to the glob package. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Don't run glob tests on the browser. Created 6 years, 3 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
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.utils; 5 library glob.utils;
6 6
7 import 'package:path/path.dart' as p;
8
7 /// A range from [min] to [max], inclusive. 9 /// A range from [min] to [max], inclusive.
8 class Range { 10 class Range {
9 /// The minimum value included by the range. 11 /// The minimum value included by the range.
10 final int min; 12 final int min;
11 13
12 /// The maximum value included by the range. 14 /// The maximum value included by the range.
13 final int max; 15 final int max;
14 16
15 /// Whether this range covers only a single number. 17 /// Whether this range covers only a single number.
16 bool get isSingleton => min == max; 18 bool get isSingleton => min == max;
(...skipping 29 matching lines...) Expand all
46 List<String> groups(List<int> groupIndices) => 48 List<String> groups(List<int> groupIndices) =>
47 groupIndices.map((index) => group(index)).toList(); 49 groupIndices.map((index) => group(index)).toList();
48 } 50 }
49 51
50 final _quote = new RegExp(r"[+*?{}|[\]\\().^$-]"); 52 final _quote = new RegExp(r"[+*?{}|[\]\\().^$-]");
51 53
52 /// Returns [contents] with characters that are meaningful in regular 54 /// Returns [contents] with characters that are meaningful in regular
53 /// expressions backslash-escaped. 55 /// expressions backslash-escaped.
54 String regExpQuote(String contents) => 56 String regExpQuote(String contents) =>
55 contents.replaceAllMapped(_quote, (char) => "\\${char[0]}"); 57 contents.replaceAllMapped(_quote, (char) => "\\${char[0]}");
58
59 /// Returns [path] with all its separators replaced with forward slashes.
60 ///
61 /// This is useful when converting from Windows paths to globs.
62 String separatorToForwardSlash(String path) {
63 if (p.context != p.Style.windows) return path;
64 return path.replaceAll('\\', '/');
65 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698