class IO::Notification::Change
class IO::Notification::Change {}
IO::Notification.watch-path($path)
as well as
IO::Path.watch produce a
Supply
of IO::Notification::Change
events for a file or directory, depending on
what is used as the $path
argument or IO::Path object.
Here is a small example that prints the first ten
FileChanged
-notifications for the current working directory:
my $finish = Promise.new;
my $count = 0;
IO::Notification.watch-path($*CWD).act( -> $change {
$count++ if $change.event ~~ FileChanged;
say "($count) $change.path(): $change.event()";
$finish.keep if $count >= 10;
});
await $finish;
The type of the change is very much dependent both on the platform and on specific system calls that were used to 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 path
Returns the path of the file that's being watched.
method event
Returns the type of event: FileChanged
or FileRenamed
.
method IO
Returns a handle of the file that's being watched.
method gist
multi method gist(IO::Notification::Change:D:)
Returns the path and event attributes, separated by semicolon.