Skip to content

Commit

Permalink
[docs,io] Clarify that isDirectory is not meaningful for FileSystemDe…
Browse files Browse the repository at this point in the history
…leteEvent.

Bug: #55130
Change-Id: I43c95218cd9f6b87ab242affa8cc2b9d42df7d96
CoreLibraryReviewExempt: documentation-only change
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/357663
Reviewed-by: Lasse Nielsen <[email protected]>
Reviewed-by: Brian Quinlan <[email protected]>
Commit-Queue: Brian Quinlan <[email protected]>
  • Loading branch information
brianquinlan authored and Commit Queue committed Mar 30, 2024
1 parent 50360c5 commit 9b2b0ac
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
21 changes: 14 additions & 7 deletions sdk/lib/io/file_system_entity.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 9b2b0ac

Please sign in to comment.