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

Side by Side Diff: sdk/lib/io/file_system_entity.dart

Issue 131373002: Fix listing of '' and '/'. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 11 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 | « sdk/lib/io/directory_impl.dart ('k') | no next file » | 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) 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 class FileSystemEntityType { 7 class FileSystemEntityType {
8 static const FILE = const FileSystemEntityType._internal(0); 8 static const FILE = const FileSystemEntityType._internal(0);
9 static const DIRECTORY = const FileSystemEntityType._internal(1); 9 static const DIRECTORY = const FileSystemEntityType._internal(1);
10 static const LINK = const FileSystemEntityType._internal(2); 10 static const LINK = const FileSystemEntityType._internal(2);
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 } 599 }
600 600
601 static _throwIfError(Object result, String msg, [String path]) { 601 static _throwIfError(Object result, String msg, [String path]) {
602 if (result is OSError) { 602 if (result is OSError) {
603 throw new FileSystemException(msg, path, result); 603 throw new FileSystemException(msg, path, result);
604 } else if (result is ArgumentError) { 604 } else if (result is ArgumentError) {
605 throw result; 605 throw result;
606 } 606 }
607 } 607 }
608 608
609 static String _trimTrailingPathSeparators(String path) { 609 static String _trimTrailingPathSeparators(String path) {
Søren Gjesse 2014/01/09 10:33:10 Is this method still used?
Anders Johnsen 2014/01/09 10:33:38 Yes, by watching.
610 // Don't handle argument errors here. 610 // Don't handle argument errors here.
611 if (path is! String) return path; 611 if (path is! String) return path;
612 if (Platform.operatingSystem == 'windows') { 612 if (Platform.operatingSystem == 'windows') {
613 while (path.length > 1 && 613 while (path.length > 1 &&
614 (path.endsWith(Platform.pathSeparator) || 614 (path.endsWith(Platform.pathSeparator) ||
615 path.endsWith('/'))) { 615 path.endsWith('/'))) {
616 path = path.substring(0, path.length - 1); 616 path = path.substring(0, path.length - 1);
617 } 617 }
618 } else { 618 } else {
619 while (path.length > 1 && path.endsWith(Platform.pathSeparator)) { 619 while (path.length > 1 && path.endsWith(Platform.pathSeparator)) {
620 path = path.substring(0, path.length - 1); 620 path = path.substring(0, path.length - 1);
621 } 621 }
622 } 622 }
623 return path; 623 return path;
624 } 624 }
625
626 static String _ensureTrailingPathSeparators(String path) {
627 // Don't handle argument errors here.
628 if (path is! String) return path;
629 if (path.isEmpty) path = '.';
630 if (Platform.operatingSystem == 'windows') {
631 while (!path.endsWith(Platform.pathSeparator) && !path.endsWith('/')) {
632 path = "$path${Platform.pathSeparator}";
633 }
634 } else {
635 while (!path.endsWith(Platform.pathSeparator)) {
636 path = "$path${Platform.pathSeparator}";
637 }
638 }
639 return path;
640 }
625 } 641 }
626 642
627 643
628 /** 644 /**
629 * Base event class emitted by [FileSystemEntity.watch]. 645 * Base event class emitted by [FileSystemEntity.watch].
630 */ 646 */
631 class FileSystemEvent { 647 class FileSystemEvent {
632 /** 648 /**
633 * Bitfield for [FileSystemEntity.watch], to enable [FileSystemCreateEvent]s. 649 * Bitfield for [FileSystemEntity.watch], to enable [FileSystemCreateEvent]s.
634 */ 650 */
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 return buffer.toString(); 756 return buffer.toString();
741 } 757 }
742 } 758 }
743 759
744 760
745 class _FileSystemWatcher { 761 class _FileSystemWatcher {
746 external static Stream<FileSystemEvent> watch( 762 external static Stream<FileSystemEvent> watch(
747 String path, int events, bool recursive); 763 String path, int events, bool recursive);
748 external static bool get isSupported; 764 external static bool get isSupported;
749 } 765 }
OLDNEW
« no previous file with comments | « sdk/lib/io/directory_impl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698