class IO::Notification
Asynchronous notification for file and directory changes
(:FileChanged(1), :FileRenamed(2));
IO::Notification.watch-path($path)
produces a Supply of IO::Notification::Change
events for a file or directory.
Here is a small example that prints the first ten FileChanged
-notifications for the current working directory:
my = Promise.new;my = 0;IO::Notification.watch-path().act( ->);await ;
The type of the change is very much dependent both on the platform and on specific system calls that were used initiate the change. At this point in time you should not rely on the type of change in general, and test your particular situation.
Methods
method watch-path
method watch-path(IO::Notification: Str() , : = )
Returns a Supply that emits IO::Notification::Change
objects.
If $path
is a file, only modifications of that file are reported. If $path
is a directory, both modifications to the directory itself (for example permission changes) and to files in the directory (including new files in the directory) are reported.
:$scheduler
allows you to specify which thread scheduler is responsible for the notification stream.