P
Peter Wyzl
I have a program using Win32::FileSecurity which has a known bug, in that it
croaks rather than reporting errors via $! as it documents. I am trying to
run a process agains multiple directories where I expect to encounter some
errors, but Win32::FileSecurity croaks when it encounters the errors. How
can I prevent the croak? Is there some way to trap it? I have looked into
perlfaq8 about trapping signals but I don't see that I can apply it to my
situation.
My script is only slightly modified from the example in the docs:
#!/perl -w
use strict;
# Gets the rights for all files listed on the command line.
use Win32::FileSecurity qw(Get EnumerateRights);
opendir (DIR, '.') or die "Unable to read directory $!\n";
my @dirs;
while (my $dir = readdir DIR){
next unless -d $dir;
push @dirs, $dir;
}
closedir DIR;
foreach( @dirs ) {
next unless -e $_ ;
print "$_\n";
my (%hash, @happy);
if ( Get( $_, \%hash ) ) { # Croaks Here on some dirs
while( my($name, $mask) = each %hash ) {
print "$name:\n\t";
EnumerateRights( $mask, \@happy ) ;
print join( "\n\t", @happy ), "\n";
}
}
else {
print( "Error #", int( $! ), ": $!" ) ; # Never gets here
}
}
Any suggestions or pointers to further reading would be most appreciated.
P
croaks rather than reporting errors via $! as it documents. I am trying to
run a process agains multiple directories where I expect to encounter some
errors, but Win32::FileSecurity croaks when it encounters the errors. How
can I prevent the croak? Is there some way to trap it? I have looked into
perlfaq8 about trapping signals but I don't see that I can apply it to my
situation.
My script is only slightly modified from the example in the docs:
#!/perl -w
use strict;
# Gets the rights for all files listed on the command line.
use Win32::FileSecurity qw(Get EnumerateRights);
opendir (DIR, '.') or die "Unable to read directory $!\n";
my @dirs;
while (my $dir = readdir DIR){
next unless -d $dir;
push @dirs, $dir;
}
closedir DIR;
foreach( @dirs ) {
next unless -e $_ ;
print "$_\n";
my (%hash, @happy);
if ( Get( $_, \%hash ) ) { # Croaks Here on some dirs
while( my($name, $mask) = each %hash ) {
print "$name:\n\t";
EnumerateRights( $mask, \@happy ) ;
print join( "\n\t", @happy ), "\n";
}
}
else {
print( "Error #", int( $! ), ": $!" ) ; # Never gets here
}
}
Any suggestions or pointers to further reading would be most appreciated.
P