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

Unified Diff: utils/pub/io.dart

Issue 13293006: Work around issue 4928. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 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 | utils/tests/pub/io_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils/pub/io.dart
diff --git a/utils/pub/io.dart b/utils/pub/io.dart
index 7848915628c84a57047b05ec5dddfccdf86b7653..575764dab571d798e6b49bfde3eca51c8b0b8356 100644
--- a/utils/pub/io.dart
+++ b/utils/pub/io.dart
@@ -33,7 +33,7 @@ bool entryExists(String path) =>
/// Returns whether [link] exists on the file system. This will return `true`
/// for any symlink, regardless of what it points at or whether it's broken.
-bool linkExists(String path) => new Link(path).existsSync();
+bool linkExists(String link) => new Link(link).existsSync();
/// Returns whether [file] exists on the file system. This will return `true`
/// for a symlink only if that symlink is unbroken and points to a file.
@@ -146,7 +146,15 @@ List<String> listDir(String dir, {bool recursive: false,
log.io("Listing directory $dir.");
var children = [];
- for (var entity in new Directory(dir).listSync()) {
+ for (var entity in new Directory(dir).listSync(followLinks: false)) {
+ // TODO(nweiz): remove this when issue 4928 is fixed.
+ if (entity is Link) {
+ var link = entity.path;
+ // We treat broken symlinks as files, in that we don't want to recurse
+ // into them.
+ entity = dirExists(link) ? new Directory(link) : new File(link);
+ }
+
if (entity is File) {
var file = entity.path;
if (!includeHiddenFiles && path.basename(file).startsWith('.')) {
« no previous file with comments | « no previous file | utils/tests/pub/io_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698