Import std.io.watcher
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.
Examples
Local watcher = Try FileWatcher(Path("assets"))
Local event = watcher.Next()
While event != Null
Print("{event.Kind}: {event.Path}")
event = watcher.Next()
End While-
The file or folder it watches.
-
Starts watching what's at the
path, which has to be there. -
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.
-
The next event if one's come, or Null.
-
Next's Async twin, which waits on the main thread instead of blocking it.
-
Stops watching, dropping the events not taken, so what waits for one, and each Next, gets Null. A second Close does nothing.
Report an issue with this page or with FutureBlitz on GitHub.