From 9b2b0ac848af91baef45cd56c5b030fa3ef53c0b Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Sat, 30 Mar 2024 01:03:08 +0000 Subject: [PATCH] [docs,io] Clarify that isDirectory is not meaningful for FileSystemDeleteEvent. Bug: https://github.com/dart-lang/sdk/issues/55130 Change-Id: I43c95218cd9f6b87ab242affa8cc2b9d42df7d96 CoreLibraryReviewExempt: documentation-only change Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/357663 Reviewed-by: Lasse Nielsen Reviewed-by: Brian Quinlan Commit-Queue: Brian Quinlan --- CHANGELOG.md | 3 +++ sdk/lib/io/file_system_entity.dart | 21 ++++++++++++++------- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 063c339c9fb..b1851a6bc14 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,6 +41,9 @@ advantage of these improvements, set your package's `stderr`. Classes that `implement Stdout` must define the `lineTerminator` field. The default semantics of `stdout` and `stderr` are not changed. +- Deprecates `FileSystemDeleteEvent.isDirectory`, which always returns + `false`. + [#53863]: https://github.com/dart-lang/sdk/issues/53863 #### `dart:js_interop` diff --git a/sdk/lib/io/file_system_entity.dart b/sdk/lib/io/file_system_entity.dart index 29be1e9075b..723d1e69941 100644 --- a/sdk/lib/io/file_system_entity.dart +++ b/sdk/lib/io/file_system_entity.dart @@ -897,11 +897,13 @@ sealed class FileSystemEvent { /// relative. final String path; - /// Is `true` if the event target was a directory. + /// Whether the event target is a directory. /// - /// Note that if the file has been deleted by the time the event has arrived, - /// this will always be `false` on Windows. In particular, it will always be - /// `false` for `delete` events. + /// The value will always be `false` for [FileSystemDeleteEvent]. + /// + /// On Windows, the value may also be `false` for a create, move or + /// modify event on a directory, if that directory was deleted + /// soon after this create, modify or move event occured. final bool isDirectory; FileSystemEvent._(this.type, this.path, this.isDirectory); @@ -936,10 +938,15 @@ final class FileSystemModifyEvent extends FileSystemEvent { final class FileSystemDeleteEvent extends FileSystemEvent { /// Constructs a new [FileSystemDeleteEvent]. FileSystemDeleteEvent(String path, bool isDirectory) - : super._(FileSystemEvent.delete, path, isDirectory); + : super._(FileSystemEvent.delete, path, false); - String toString() => - "FileSystemDeleteEvent('$path', isDirectory=$isDirectory)"; + String toString() => "FileSystemDeleteEvent('$path')"; + + /// Whether the file system object was a directory. + /// + /// The value will always be `false` for [FileSystemDeleteEvent]. + @Deprecated('always false for FileSystemDeleteEvent') + bool get isDirectory => false; } /// File system event for moving of file system objects.