in reply to How do I know if I can delete a file/folder?
I'm probably way off here, cos otherwise someone else would have spotted this I'm sure but...at the risk of egg-on-my-face.
The only reason I can think of for wanting to know if you can delete a file, is because you want to delete that file?
So, if you want to delete it, but want to take some other action (like changing permissions) if you cannot delete the file, simply try, and take those actions if the delete fails.
for (@comdemnedFilesOrDirs){ if( -f && !unlink or -d _ && !rmdir ){ # change permission here (uncomment as appropriate) # chmod( nnn, $_ ) # Win32::FileSecurity::Set( $_, Win32::FileSecurity::MakeMask( + qw( CHANGE ))) and redo; } }
You'll will need to add code to check that the change of permissions worked and last or die "....$!" incase the userid the code is running as doesn't have permission to change the permissions, otherwise this would become an endless loop.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: How do I know if I can delete a file/folder?
by greenFox (Vicar) on Jul 26, 2002 at 09:18 UTC |