in reply to Deleting Files on Win32
If you want to delete a directory and all of its the subdirectories, use rmtree from File::Path.
The alternative is not very hard.
use File::Spec::Functions qw( catfile ); my $dir = ...; opendir(my $dh, $dir_name) or die("Unable to list contents of dir \"$dir_name\": $!\n"); while (defined(my $file_name = readdir($dh))) { my $full_name = catpath($dir_name, $file_name); next unless -f $full_name; unlink($full_name) or warn("Unable to delete file \"$full_name\": $!\n"); }
I want to secure delete shred these files too.
rmtree and unlink don't do that. It might be easier and more reliable to use an existing tool (directly or by calling it from Perl if you want some automation).
|
|---|