in reply to win32::ChangeNotify replacement for Unix?
You could keep a data structure that represents the directory structure, and recursively run through that structure looking for changes, if you find one .. write it to a log or notify the proper processes/authorities and add it to the data stucture. I believe recursion along with the perl functions opendir readdir closedir will provide you with what you need.
Here is a function I use to log the directory structure of a give root node... keep in mind I'm not keeping track of it in the data structure method that I suggested, I'm simply writing it to a log.
##Recursive routine to print out all the files & folders under a given + root node sub mapMe { #Get the parameter my ($handle) = shift; #Open the directory passed to the subroutine opendir(SPROUT,$handle); #read the entries my @entries = readdir(SPROUT); #Close the directory closedir(SPROUT); my $log_entry; foreach my $i (2..(scalar(@entries)-1)) { #Format the handle for the next call my $param_handle = $handle."\\".$entries[$i]; #If its a directory and its not null if(opendir(TEST,$param_handle) and $entries[$i]) { #Close the directory closedir(TEST); #Strip the handle for log writing purposes $handle =~ s{\\\\}{\\}g; #Construct and write the log $log_entry = "\n".$handle."\\".$entries[$i]."\n"; $log->write($log_entry,length($log_entry)); #recurse the directory mapMe($param_handle); } elsif($entries[$i]) { #Construct and write the log $log_entry = "*".$entries[$i]."\n"; $log->write($log_entry,length($log_entry)); } } }
|
|---|