$notify = Win32::ChangeNotify->new($path, $subtree, 'FILE_NAME | LAST_
+WRITE' );
$nofify->wait; will return for either type of event. It's then up to you to go off and find what changed by scanning the directory in question.
To simplify the discovery, you can create mutiple notify objects and then wait_any() (from Win32::Event), and then you what type of change you should look for:
use Win32::Event qw[ wait_any ];
...
my $notifyFileName = Win32::ChangeNotify->new($path, $subtree, 'FILE_N
+AME' );
my $notifyLastWrite = Win32::ChangeNotify->new($path, $subtree, 'LAST_
+WRITE' );
my @nfys = ( $notifyFileName, $notifyLastWrite );
defined( my $signalled = wait_any( @notify, $timeout ) )
or die "Mutex error: $^E";
if( $signalled == 1 ) {
## Look for fine name change
}
elsif( $signalled == 2 ) {
## Look for last write change
}
elsif( $signalled < 0 ) {
warn "Abaindoned mutex"; ## ?
}
else {
## Wait timed out (only if timeout used)
}
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
|