Skip to content
FutureBlitz

    Install

    Import std.io.watcher

    std.io.watcher

    std.io's file watcher: what happens to a file, or to what's in a folder, as the OS tells libuv, which a FileWatcher queues for the program to take in turn, waiting for it, awaiting it, or not.

    std/io/watcher.fb

    Types

    FileEventKind enum

    Public Enum FileEventKind

    What happened at a path, which a watcher tells by the names it knows are there, since OSes call these differently.

    std/io/watcher.fb, line 22

    • CREATED enum member #

      Something came there, as the new name of a rename does.

    • CHANGED enum member #

      It changed, as a file that another is renamed over does.

    • REMOVED enum member #

      It went, as the old name of a rename does.

    FileEvent struct

    Public Struct FileEvent

    What happened, and where.

    std/io/watcher.fb, line 32

    • Public ReadOnly Field Kind: FileEventKind field #

      What happened.

    • Public ReadOnly Field Path: Path field #

      The file or folder it happened to.

    FileWatcher class

    Public Class FileWatcher

    Watches a file, or what's in a folder, but not the folders in it, from when it's made until it's closed or its last reference goes. An OS can tell of one change more than once, as when a write comes in parts, and of a change it makes itself, as of a folder's times. A watched file or folder that's removed may go unwatched on some OSes, even once it's back.

    std/io/watcher.fb, line 48

    • Public ReadOnly Field Path: Path field #

      The file or folder it watches.

    • Public New(path: Path) Throws IOError constructor #

      Starts watching what's at the path, which has to be there.

    • Public Method Next(): FileEvent? method #

      The next event, waiting for it, or Null once it's closed. Nothing else runs on this thread meanwhile, so one that nothing comes to waits forever.

    • Public Method TryNext(): FileEvent? method #

      The next event if one's come, or Null.

    • Public Async Method NextAsync(): FileEvent? method #

      Next's Async twin, which waits on the main thread instead of blocking it.

    • Public Method Close() method #

      Stops watching, dropping the events not taken yet, so what waits for one, and each later Next, gets Null. A second Close does nothing.

    Report an issue with this page or with FutureBlitz on GitHub.