(:FileChanged(1), :FileRenamed(2));
Essentially, this class exists as a placeholder for the IO::Notification.watch-path($path)
method, that produces a Supply of IO::Notification::Change
events for a file or directory.
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.
The :$scheduler
named argument allows you to specify which thread scheduler is going to be responsible for the notification stream; it can be omitted if the default scheduler is used.
my = IO::Notification.watch-path( "/var/log/syslog" );.tap( -> );sleep 60;
This snippet of code sets a watch on the system log file, emitting the kind of event that has occurred or capturing an error otherwise; the created Supply
is tapped, and the event printed. It does so for 60 minutes, emitting something like this:
Got /var/log/syslog: FileChangedGot /var/log/syslog: FileChangedGot /var/log/syslog: FileChangedGot /var/log/syslog: FileChangedGot /var/log/syslog: FileChangedGot /var/log/syslog: FileChangedGot /var/log/syslog: FileChangedGot /var/log/syslog: FileChanged
The only kind of information this method provides is the bare fact that something has change or been renamed. You will need to actually open and read the file or directory to check the actual changes.