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.
In reply to Re: How do I know if I can delete a file/folder?
by BrowserUk
in thread How do I know if I can delete a file/folder?
by soffen
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |