diff --git a/CHANGELOG.md b/CHANGELOG.md index 460c76d80..1852a4c98 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ ## 1.17.5 +* Avoid recursively listing directories when finding the canonical name of a + file on case-insensitive filesystems. + * Fix importing files relative to `package:`-imported files. ### Dart API diff --git a/lib/src/executable/options.dart b/lib/src/executable/options.dart index 82ef17dac..e92e40fbd 100644 --- a/lib/src/executable/options.dart +++ b/lib/src/executable/options.dart @@ -356,7 +356,7 @@ class ExecutableOptions { /// [destination] directories. Map _listSourceDirectory(String source, String destination) { var map = {}; - for (var path in listDir(source)) { + for (var path in listDir(source, recursive: true)) { var basename = p.basename(path); if (basename.startsWith("_")) continue; diff --git a/lib/src/io/interface.dart b/lib/src/io/interface.dart index 16653d651..a41d3b14c 100644 --- a/lib/src/io/interface.dart +++ b/lib/src/io/interface.dart @@ -79,9 +79,11 @@ bool dirExists(String path) => null; /// necessary. void ensureDir(String path) => null; -/// Recursively lists the files (not sub-directories) of the directory at -/// [path]. -Iterable listDir(String path) => null; +/// Lists the files (not sub-directories) in the directory at [path]. +/// +/// If [recursive] is `true`, this lists files in directories transitively +/// beneath [path] as well. +Iterable listDir(String path, {bool recursive = false}) => null; /// Returns the modification time of the file at [path]. DateTime modificationTime(String path) => null; diff --git a/lib/src/io/node.dart b/lib/src/io/node.dart index f7cec7bb5..77558b1b7 100644 --- a/lib/src/io/node.dart +++ b/lib/src/io/node.dart @@ -191,14 +191,23 @@ void ensureDir(String path) { }); } -Iterable listDir(String path) { - Iterable list(String parent) => - _fs.readdirSync(parent).expand((child) { - var path = p.join(parent, child as String); - return dirExists(path) ? listDir(path) : [path]; - }); - - return _systemErrorToFileSystemException(() => list(path)); +Iterable listDir(String path, {bool recursive = false}) { + return _systemErrorToFileSystemException(() { + if (!recursive) { + return _fs + .readdirSync(path) + .map((child) => p.join(path, child as String)) + .where((child) => !dirExists(child)); + } else { + Iterable list(String parent) => + _fs.readdirSync(parent).expand((child) { + var path = p.join(parent, child as String); + return dirExists(path) ? list(path) : [path]; + }); + + return list(path); + } + }); } DateTime modificationTime(String path) => diff --git a/lib/src/io/vm.dart b/lib/src/io/vm.dart index 849f7dc9d..e439609c3 100644 --- a/lib/src/io/vm.dart +++ b/lib/src/io/vm.dart @@ -71,10 +71,11 @@ bool dirExists(String path) => io.Directory(path).existsSync(); void ensureDir(String path) => io.Directory(path).createSync(recursive: true); -Iterable listDir(String path) => io.Directory(path) - .listSync(recursive: true) - .where((entity) => entity is io.File) - .map((entity) => entity.path); +Iterable listDir(String path, {bool recursive = false}) => + io.Directory(path) + .listSync(recursive: recursive) + .where((entity) => entity is io.File) + .map((entity) => entity.path); DateTime modificationTime(String path) { var stat = io.FileStat.statSync(path);