Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Making a perl program look like a regular file on Win32?

by vladdrak (Monk)
on Mar 03, 2004 at 19:14 UTC ( #333656=note: print w/replies, xml ) Need Help??


in reply to Making a perl program look like a regular file on Win32?

You can subscribe to Win32 ChangeNotify messages, which would let you know when a file changed for whatever reason. I'm not sure if this helps in your situation, but it is kinda cool. If you don't have Win32::ChangeNotify installed, you can get it via PPM if you run ActiveState ala "ppm install Win32-ChangeNotify" or from CPAN using "perl -MCPAN -e 'install Win32::ChangeNotify'". Here's some sample code:
use strict; my $logfile = "D:\\ChangeNotify.txt"; my $path = "D:\\"; use Win32::ChangeNotify; ChangeWatch(); sub ChangeWatch { #$filter can contain any of the below seperated by a | # #ATTRIBUTES Any attribute change #DIR_NAME Any directory name change #FILE_NAME Any file name change #LAST_WRITE Any change to a file's last write time #SECURITY Any security descriptor change #SIZE Any change in a file's size my $filter = LAST_WRITE; my ($path,$subtree); my $notify = Win32::ChangeNotify->new($path,$subtree,$filter); $notify->wait or warn "Something failed: $!\n"; Notify($path,$subtree); $notify->reset; ChangeWatch(); } sub Notify { my ($path,$subtree)=@_; open(FILE,">>$logfile) or die "could not optn $logfile: $!"; print FILE scalar localtime . "Change Detected at $path $subtree\n"; close FILE; }
-Vlad

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://333656]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2023-02-06 05:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer not to run the latest version of Perl because:







    Results (33 votes). Check out past polls.

    Notices?