Subject: | global filehandle DIR locks directory (test and patch included). |
I was trying to remove with File::Path::rmtree under cygwin and hitting
an error, 'directory not empty'. To reproduce:
perl -MFile::Path -MFilesys::DiskUsage -E '
mkpath("/tmp/a/b/c");
Filesys::DiskUsage::du("/tmp/a/b");
rmtree("/tmp/a");
'
The solution was to make the dirhandle for opendir a local variable.
Calling closedir also solves the problem.
diff:
208c208
< opendir( my $dh, $_ );
---
Show quoted text
> opendir(DIR,$_);
214c214
< }, map {"$dir/$_"} grep {! /^\.\.?$/}
readdir $dh );
---
Show quoted text> }, map {"$dir/$_"} grep {! /^\.\.?$/}
readdir DIR );