Foggy Bottoms has asked for the wisdom of the Perl Monks concerning the following question:
Test : while my code is running I start up a new DOS prompt (I'm using WinNT 4.0) and do the following :The winnt folder is banned but the personal one isn't so the scan is activated... When I do the first mkdir I get in the other window (the perl one) the following :
C:\WINNT\Profiles\702031609\Personal>mkdir toto C:\WINNT\Profiles\702031609\Personal>rmdir toto C:\WINNT\Profiles\702031609\Personal>mkdir toto
Output :But when I run the rmdir and the last mkdir, it fails... (it doesn't return anything but the while print...).c:\WINNT\Profiles\702031609\Personal (c:\WINNT\Profiles\702031609\Pers +onal) key : filename -> content : c:\WINNT\Profiles\702031609\Personal key : action -> content : FILE_ACTION_MODIFIED ---while---
and the call to the function :sub startScan { # read parameters my @wantedF = @{+shift}; my @bannedF = @{+shift}; my $scanType= shift; my $folder = "c:\\"; my $obj = new Win32::AdvNotify() or die ("Can't create AdvNotify ob +ject");# create watch object # scan main drive (c:\) for any possible change. (my $thread=$obj->StartThread(Directory=>$folder,Filter=>All,WatchS +ubtree=>Yes)) or die ("Can't start thread."); $thread->EnableWatch() or die "Problem starting EnableWatch()\n"; $obj->Wait(Win32::AdvNotify::INFINITE); # block code here as long a +s no change comes up. # store data of file/folder changed my @data; my $ret = $obj->Read(\@data); my %changes; for (0..@data-1) # for each change detected { my $filename = @data[$_]->{'Directory'}.@data[$_]->{'FileName'}; my $path=$filename; if (not isFolder($filename)) { $filename =~ /^(.*)\\/; # returns path part of the filename $path = $1; } if (compareFolder($path,$scanType,\@wantedF,\@bannedF)==ACCEPTED +) { # print "@data[$_]->{'FileName'} : ACCEPTED\n"; # print "Action :".$ActionName{@data[$_]->{'Action'}}."\n" +; # debug purposes # print "---------------------------\n"; if ( isFolder($filename) or $filename =~ /\.doc|\.ppt|\.xls|\ +.pdf$/ ) { print "$filename ($path)\n"; $changes{filename} = $filename; $changes{action} = $ActionName{@data[$_]->{'Action'}}; } } } return %changes; }
I've a feeling there's a memory problem with AdvNotify : perhaps I should clean up after its use like shutting it down or deleting change detections after I dealt with them (or is there no need ?).my @wantedF; # folders to be scanned my @bannedF; # banned folders not to be scanned @wantedF = ('C:/My Documents', 'C:/WINNT/Profiles/702031609/Personal', 'd:/', 'D:/brossad/photos'); @bannedF = ('c:/win32app', 'C:/TEMP', 'c:/recycler', 'c:/winnt', 'd:/perl', 'd:/brossad'); while (1) { my %changes = startScan(\@wantedF,\@bannedF,INC_SUBDIRS); foreach my $k (keys %changes) { print "key : $k -> content : $changes{$k}\n"; } print "---while---\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Cleaning up with Free...
by Foggy Bottoms (Monk) on Aug 20, 2003 at 15:28 UTC |