mirror of
https://github.com/dart-lang/sdk
synced 2024-09-15 22:41:41 +00:00
Work around issue 4928.
Review URL: https://codereview.chromium.org//13293006 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@20704 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
parent
1049bd30dc
commit
16367f141e
|
@ -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('.')) {
|
||||
|
|
|
@ -119,6 +119,20 @@ main() {
|
|||
]));
|
||||
}), completes);
|
||||
});
|
||||
|
||||
test('treats a broken symlink as a file', () {
|
||||
expect(withTempDir((temp) {
|
||||
writeTextFile(path.join(temp, 'file1.txt'), '');
|
||||
createDir(path.join(temp, 'dir'));
|
||||
createSymlink(path.join(temp, 'dir'), path.join(temp, 'linkdir'));
|
||||
deleteEntry(path.join(temp, 'dir'));
|
||||
|
||||
expect(listDir(temp, recursive: true), unorderedEquals([
|
||||
path.join(temp, 'file1.txt'),
|
||||
path.join(temp, 'linkdir')
|
||||
]));
|
||||
}), completes);
|
||||
});
|
||||
});
|
||||
|
||||
testExistencePredicate("entryExists", entryExists,
|
||||
|
|
Loading…
Reference in a new issue