OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 part of dart.io; | 5 part of dart.io; |
6 | 6 |
7 /** | 7 /** |
8 * The type of an entity on the file system, such as a file, directory, or link. | 8 * The type of an entity on the file system, such as a file, directory, or link. |
9 * | 9 * |
10 * These constants are used by the [FileSystemEntity] class | 10 * These constants are used by the [FileSystemEntity] class |
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 return response; | 475 return response; |
476 }); | 476 }); |
477 } | 477 } |
478 | 478 |
479 static final RegExp _absoluteWindowsPathPattern = | 479 static final RegExp _absoluteWindowsPathPattern = |
480 new RegExp(r'^(\\\\|[a-zA-Z]:[/\\])'); | 480 new RegExp(r'^(\\\\|[a-zA-Z]:[/\\])'); |
481 | 481 |
482 /** | 482 /** |
483 * Returns a [bool] indicating whether this object's path is absolute. | 483 * Returns a [bool] indicating whether this object's path is absolute. |
484 * | 484 * |
485 * On Windows, a path is absolute if it starts with \\ or a drive letter | 485 * On Windows, a path is absolute if it starts with \\\\ or a drive letter |
486 * between a and z (upper or lower case) followed by :\ or :/. | 486 * between a and z (upper or lower case) followed by :\\ or :/. |
487 * On non-Windows, a path is absolute if it starts with /. | 487 * On non-Windows, a path is absolute if it starts with /. |
488 */ | 488 */ |
489 bool get isAbsolute { | 489 bool get isAbsolute { |
490 if (Platform.isWindows) { | 490 if (Platform.isWindows) { |
491 return path.startsWith(_absoluteWindowsPathPattern); | 491 return path.startsWith(_absoluteWindowsPathPattern); |
492 } else { | 492 } else { |
493 return path.startsWith('/'); | 493 return path.startsWith('/'); |
494 } | 494 } |
495 } | 495 } |
496 | 496 |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 external static _resolveSymbolicLinks(String path); | 617 external static _resolveSymbolicLinks(String path); |
618 | 618 |
619 // Finds the next-to-last component when dividing at path separators. | 619 // Finds the next-to-last component when dividing at path separators. |
620 static final RegExp _parentRegExp = Platform.isWindows ? | 620 static final RegExp _parentRegExp = Platform.isWindows ? |
621 new RegExp(r'[^/\\][/\\]+[^/\\]') : | 621 new RegExp(r'[^/\\][/\\]+[^/\\]') : |
622 new RegExp(r'[^/]/+[^/]'); | 622 new RegExp(r'[^/]/+[^/]'); |
623 | 623 |
624 /** | 624 /** |
625 * Removes the final path component of a path, using the platform's | 625 * Removes the final path component of a path, using the platform's |
626 * path separator to split the path. Will not remove the root component | 626 * path separator to split the path. Will not remove the root component |
627 * of a Windows path, like "C:\" or "\\server_name\". | 627 * of a Windows path, like "C:\\" or "\\\\server_name\\". |
628 * Ignores trailing path separators, and leaves no trailing path separators. | 628 * Ignores trailing path separators, and leaves no trailing path separators. |
629 */ | 629 */ |
630 static String parentOf(String path) { | 630 static String parentOf(String path) { |
631 int rootEnd = -1; | 631 int rootEnd = -1; |
632 if (Platform.isWindows) { | 632 if (Platform.isWindows) { |
633 if (path.startsWith(_absoluteWindowsPathPattern)) { | 633 if (path.startsWith(_absoluteWindowsPathPattern)) { |
634 // Root ends at first / or \ after the first two characters. | 634 // Root ends at first / or \ after the first two characters. |
635 rootEnd = path.indexOf(new RegExp(r'[/\\]'), 2); | 635 rootEnd = path.indexOf(new RegExp(r'[/\\]'), 2); |
636 if (rootEnd == -1) return path; | 636 if (rootEnd == -1) return path; |
637 } else if (path.startsWith('\\') || path.startsWith('/')) { | 637 } else if (path.startsWith('\\') || path.startsWith('/')) { |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
832 return buffer.toString(); | 832 return buffer.toString(); |
833 } | 833 } |
834 } | 834 } |
835 | 835 |
836 | 836 |
837 class _FileSystemWatcher { | 837 class _FileSystemWatcher { |
838 external static Stream<FileSystemEvent> _watch( | 838 external static Stream<FileSystemEvent> _watch( |
839 String path, int events, bool recursive); | 839 String path, int events, bool recursive); |
840 external static bool get isSupported; | 840 external static bool get isSupported; |
841 } | 841 } |
OLD | NEW |