develooper Front page | perl.perl5.porters | Postings from March 2000

File::Spec oddities.

Barrie Slaymaker
March 14, 2000 13:21
File::Spec oddities.
Message ID:
[Cc:ed to p5p]

Tim Jenness wrote:
> Oddities I found:
>   - no method to concatenate a volume to a directory tree.
>     Only a method to concatentate volume, directory and file together.
>     I assumed that I could just supply a '' as a filename and it would
>     work but that wasn't a documented feature :-)

I'll document that.  One thing that's a gotcha is the meaning of '' as a 
dirname on different platforms.  On a Mac ":::" is equivalent to '../../', 
for instance.  Here's a quick guide (from memory, to be corrected if I got
it backwards):

Calling                      Returns
===========================  ================
Mac->splitdirs( ':a:b' )     ( '', 'a', 'b' ), a relative path
VMS->splitdirs( '[.a.b]' )   ( '', 'a', 'b' ), a relative path
Unix->splitdirs( '/a/b' )    ( '', 'a', 'b' ), an absolute path
Unix->splitdirs( 'a/b' )     ( 'a', 'b' ),     a relative path

>   - It would be good if the tmpdir() function had the ability to only
>     return directories that were not tainted. For example, $ENV{TMPDIR}
>     is returned even though that is not safe. An extra argument to
>     tmpdir() could be used to only return, in this case '/tmp' explicitly.
>     Additionally, it would be good if P_tmpdir was available as well since
>     this is the default tempdir set by the system in stdio.h. That
>     would require XS though and I don't imagine we could sneak it into
>     Fcntl.xs or somewhere :-) Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About