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

Unified Diff: sdk/lib/io/directory_impl.dart

Issue 17265003: Avoid double-// on directory listing. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/standalone/io/directory_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/io/directory_impl.dart
diff --git a/sdk/lib/io/directory_impl.dart b/sdk/lib/io/directory_impl.dart
index f47ef4f90a7a1c5ff441597ba5b783cb9a81383a..55b69149844c632a6af6f4cffc300df140fa47d3 100644
--- a/sdk/lib/io/directory_impl.dart
+++ b/sdk/lib/io/directory_impl.dart
@@ -237,16 +237,35 @@ class _Directory implements Directory {
return new Directory(newPath);
}
+ static String _trimTrailingPathSeparators(String path) {
+ // Don't handle argument errors here.
+ if (path is! String) return path;
+ if (Platform.operatingSystem == 'windows') {
Søren Gjesse 2013/06/18 06:54:09 Won't this loop work for both Windows and non-Wind
Anders Johnsen 2013/06/18 06:55:26 Yeah, but it'll be twice as slow.
+ while (path.length > 1 &&
+ (path.endsWith(Platform.pathSeparator) ||
+ path.endsWith('/'))) {
+ path = path.substring(0, path.length - 1);
+ }
+ } else {
+ while (path.length > 1 && path.endsWith(Platform.pathSeparator)) {
+ path = path.substring(0, path.length - 1);
+ }
+ }
+ return path;
+ }
+
Stream<FileSystemEntity> list({bool recursive: false,
bool followLinks: true}) {
- return new _AsyncDirectoryLister(path, recursive, followLinks).stream;
+ return new _AsyncDirectoryLister(_trimTrailingPathSeparators(path),
+ recursive,
+ followLinks).stream;
}
List listSync({bool recursive: false, bool followLinks: true}) {
- if (_path is! String || recursive is! bool) {
+ if (_path is! String || recursive is! bool || followLinks is! bool) {
throw new ArgumentError();
}
- return _list(_path, recursive, followLinks);
+ return _list(_trimTrailingPathSeparators(path), recursive, followLinks);
}
String get path => _path;
« no previous file with comments | « no previous file | tests/standalone/io/directory_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698