Jos I. Boumans wrote:
>
> On 09 Sep 2007, at 07:58, John E. Malmberg wrote:
>
> Thanks, applied.
>
>> Fix directory cleanup to use catdir() for
concatenating directories
>> so that it works on VMS.
>
>
> Again, a few questions about this patch.
>
>>  -91,12 +113,15 
>> next if $file =~ /^./; # skip dot
files
>>
>> my $path = File::Spec->catfile(
$dir, $file );
>> + $file =~ s/.dir//i if $^O eq 'VMS';
>> + my $dirpath = File::Spec->catdir(
$dir, $file );
>>
>> ### directory, rmtree it
>> - if( -d $path ) {
>> - print "Deleting directory
'$path'n" if $verbose;
>> - eval { rmtree( $path ) };
>> - warn "Could not delete
'$path' while cleaning up
>> '$dir'" if $ ;
>> + if( -d $dirpath ) {
>> + print "Deleting directory
'$dirpath'n" if $verbose;
>> + eval { rmtree( $dirpath ) };
>> + warn "Could not delete
'$dirpath' while cleaning up
>> '$dir'"
>> + if $ ;
>>
>> ### regular file
>> } else {
>
>
> What's the $file =~ meant to do? Why does regular $path
not work? and why
> are we leaving $path? Is this the type of patch we
might need to do else
> where as well?
A directory name on VMS in VMS format ends with .dir when it
is
referenced as a file.
In UNIX format traditionally PERL on VMS does not remove the
'.dir',
however the VMS C library conversion routines do remove the
'.dir' and
the VMS C library routines can not handle the '.dir' being
present on
UNIX format filenames.
So code doing the fixup has on VMS has to be able to handle
both UNIX
format names and VMS format names.
The regex is wrong though, because it needs to be the last
'.dir' in the
string with an optional ';' or optional ';1' before the end.
Also to be
precise, the .dir should only be removed if the file is
known to
actually be a directory.
Directories on VMS must be version 1, ';1' or they will be
treated as
normal files by the operating system.
With ODS-5 it is possible to have a 'foo^.dir.dir' (VMS
format), and
this regex will fail. However such naming conventions are
evil.
So assuming that $dir is 'foo' and contains the directory
'bar', then
$file will contain 'bar.dir'.
In order to use it as a directory in rmtree(), it needs to
be converted
to '[foo.bar]', and catdir() will not remove the '.dir'.
So this patch, while working, could use some touchups.
-John
wb8tyw qsl.net
Personal Opinion Only
|