At 9:01 AM -0800 2/6/08, Peter (Stig) Edwards wrote:
>Trying to get Path::Class to pass it's tests on VMS Perl 5.8.7 on
>ODS-2 disk.

Thanks for looking into this.  It's one of many things on my todo list.

>
>One of the test cases is calling:
>
>  File::Spec->splitpath('t',1);
>
>So on Unix:
>
>perl -e "use File::Spec;print join('|',File::Spec->splitpath('t',0))"
>||t
>
>perl -e "use File::Spec;print join('|',File::Spec->splitpath('t',1))"
>|t|
>
>On VMS:
>
>perl -e "use File::Spec;print join('|',File::Spec->splitpath('t',0))"
>||t
>
>perl -e "use File::Spec;print join('|',File::Spec->splitpath('t',1))"
>||t
>
>It's this last command that is the problem, the expected behaviour in
>Path::Class is |t|.
>
>The doc for File::Spec->splitpath states:
>
>splitpath
>
>    Splits a path in to volume, directory, and filename portions. On
>systems with no concept of volume, returns '' for volume.
>
>        ($volume,$directories,$file) = File::Spec->splitpath( $path );
>        ($volume,$directories,$file) = File::Spec->splitpath( $path,
>$no_file );
>
>    For systems with no syntax differentiating filenames from
>directories, assumes that the last file is a path unless $no_file is
>true or a trailing separator or /. or /.. is present. On Unix, this
>means that $no_file true makes this return ( '', $path, '' ).

Well, what about systems where there *is* syntax differentiating filenames from 
directories?  I think if we substituted "cases" for "systems" we could make 
sense of the current docs.   The example that failed did not have directory 
syntax even though you were running it on a system capable of such syntax.

>    The directory portion may or may not be returned with a trailing
>'/'.
>
>    The results can be passed to "catpath()" to get back a path
>equivalent to (usually identical to) the original path.
>
>
>So I'm wondering if File::Spec::VMS->splitpath should support $no_file
>or not?  It looks like the majority of File::Spec::* modules do, I
>don't know if they all have syntax that does not differentiate
>filenames from directories.
>
>Current File::Spec::VMS splitpath is:
>
>sub splitpath {
>    my($self,$path) = @_;
>    my($dev,$dir,$file) = ('','','');
>
>    vmsify($path) =~ /(.+:)?([\[<].*[\]>])?(.*)/s;
>    return ($1 || '',$2 || '',$3);
>}
>
>This hack changes the behaviour so that File::Spec::VMS->splitpath('t',
>1) returns t as the dir and not the file.  All PathTools 3.27 tests
>still pass.
>
>sub splitpath {
>    my($self,$path, $nofile) = @_;
>    my($dev,$dir,$file) = ('','','');
>    if ( $nofile ){
>        vmsify($path) =~ /(.+:)?(.*)/s;

It might be simpler to just append $file (plus a comman) to $2 here in the 
$no_file case.

>        return ($1 || '',$2 || '',$file);
>    }
>    else {
>        vmsify($path) =~ /(.+:)?([\[<].*[\]>])?(.*)/s;
>        return ($1 || '',$2 || '',$3);
>    }
>}
>
>Just wondering if anyone has any thoughts on this?

Your approach makes sense, but I think the intention and documentation would 
need to be clarified.  Basically we're saying $no_file really means 
$the_whole_thing_consists_only_of_directory_components even on systems where 
you can usually (when not supporting a foreign syntax) tell the difference 
between directories and files at a glance.
-- 
________________________________________
Craig A. Berry
mailto:[EMAIL PROTECTED]

"... getting out of a sonnet is much more
 difficult than getting in."
                 Brad Leithauser

Reply via email to