From 47fb9fa6530a761c5a4239151e7ae89147202806 Mon Sep 17 00:00:00 2001 From: Graciliano Monteiro Passos Date: Sat, 28 Jan 2023 09:36:30 -0300 Subject: [PATCH 1/2] copyPath: add parameter `followLinks` `Directory.listSync` only returns `Link` entries if `followLinks: false` is passed. `copyPath` needs a `followLinks` parameter to configure the call of `Directory.listSync` and allow the copy of `Link` entries, as expected by line `else if (file is Link) {` --- lib/src/copy_path.dart | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/src/copy_path.dart b/lib/src/copy_path.dart index 7906f3c..dceda19 100644 --- a/lib/src/copy_path.dart +++ b/lib/src/copy_path.dart @@ -23,14 +23,17 @@ bool _doNothing(String from, String to) { /// * Existing files are over-written, if any. /// * If [to] is within [from], throws [ArgumentError] (an infinite operation). /// * If [from] and [to] are canonically the same, no operation occurs. +/// * If [followLinks] is `true`, then working links are reported as +/// directories or files, and links to directories are recursed into. /// /// Returns a future that completes when complete. -Future copyPath(String from, String to) async { +Future copyPath(String from, String to, {bool followLinks = true}) async { if (_doNothing(from, to)) { return; } await Directory(to).create(recursive: true); - await for (final file in Directory(from).list(recursive: true)) { + await for (final file + in Directory(from).list(recursive: true, followLinks: followLinks)) { final copyTo = p.join(to, p.relative(file.path, from: from)); if (file is Directory) { await Directory(copyTo).create(recursive: true); @@ -49,14 +52,17 @@ Future copyPath(String from, String to) async { /// * Existing files are over-written, if any. /// * If [to] is within [from], throws [ArgumentError] (an infinite operation). /// * If [from] and [to] are canonically the same, no operation occurs. +/// * If [followLinks] is `true`, then working links are reported as +/// directories or files, and links to directories are recursed into. /// /// This action is performed synchronously (blocking I/O). -void copyPathSync(String from, String to) { +void copyPathSync(String from, String to, {bool followLinks = true}) { if (_doNothing(from, to)) { return; } Directory(to).createSync(recursive: true); - for (final file in Directory(from).listSync(recursive: true)) { + for (final file + in Directory(from).listSync(recursive: true, followLinks: followLinks)) { final copyTo = p.join(to, p.relative(file.path, from: from)); if (file is Directory) { Directory(copyTo).createSync(recursive: true); From 81d879b4cec1e7d1cbf4bcea997e077cc48b345f Mon Sep 17 00:00:00 2001 From: Graciliano Monteiro Passos Date: Fri, 11 Aug 2023 18:19:25 -0300 Subject: [PATCH 2/2] `CHANGELOG.md`: `copyPath`/`copyPathSync`: expose parameter `followLinks` --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e723cd6..2c914aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## 1.0.5-wip * Require Dart 3.0. +* `copyPath`/`copyPathSync`: expose parameter `followLinks`. ## 1.0.4