Movatterモバイル変換


[0]ホーム

URL:


menu
  1. Dart
  2. dart:io
  3. FileSystemEntity
  4. watch method
watch
description

watch method

Stream<FileSystemEvent>watch({
  1. intevents =FileSystemEvent.all,
  2. boolrecursive =false,
})

Start watching theFileSystemEntity for changes.

The implementation uses platform-dependent event-based APIs for receivingfile-system notifications, thus behavior depends on the platform.

  • Windows: UsesReadDirectoryChangesW. The implementation onlysupports watching directories. Recursive watching is supported.

  • Linux: Usesinotify. The implementation supports watching bothfiles and directories. Recursive watching is not supported.Note: When watching files directly, delete events might not happenas expected.

  • OS X: Uses theFile System Events API.The implementation supports watching both files and directories.Recursive watching is supported.This API has several limitations:

    • Changes that occurred shortlybefore thewatch method wascalled may still appear in theStream.
    • Changes that occur in a short period of time may arriveout-of-order.
    • Multiple changes made in a single directory may be coalesced intoa singleFileSystemEvent.

The system will start listening for events once the returnedStream isbeing listened to, not when the call towatch is issued.

The returned value is an endless broadcastStream, that only stops whenone of the following happens:

  • TheStream is canceled, e.g. by callingcancel on theStreamSubscription.
  • TheFileSystemEntity being watched is deleted.
  • System Watcher exits unexpectedly. e.g. OnWindows this happens whenbuffer that receive events fromReadDirectoryChangesW overflows.

Useevents to specify what events to listen for. The constants inFileSystemEvent can be or'ed together to mix events. Default isFileSystemEvent.all.

A move event may be reported as separate delete and create events.

Implementation

Stream<FileSystemEvent> watch({  int events = FileSystemEvent.all,  bool recursive = false,}) {  // FIXME(bkonyi): find a way to do this using the raw path.  final String trimmedPath = _trimTrailingPathSeparators(path);  final IOOverrides? overrides = IOOverrides.current;  if (overrides == null) {    return _FileSystemWatcher._watch(trimmedPath, events, recursive);  }  return overrides.fsWatch(trimmedPath, events, recursive);}
  1. Dart
  2. dart:io
  3. FileSystemEntity
  4. watch method
FileSystemEntity class

[8]ページ先頭

©2009-2025 Movatter.jp