perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stas Bekman <s...@stason.org>
Subject Re: [mp2] ModPerl-Registry redirect test
Date Wed, 03 Dec 2003 07:12:22 GMT
Randy Kobes wrote:
[...]
>>I won't try to use File::Spec::Unix instead of join '/',
>>because one day it may stop loading on non-Unix...
> 
> 
> That's a good point ... However, using
>  sub t_catfile_apache {
>       my $f = canonpath join "/", @_;
>       return $f unless File::Spec->file_name_is_absolute($f);
>       return Apache::TestConfig::WIN32 ?
>           Win32::GetLongPathName($f) : $f;
>  }
> doesn't quite work on Win32 :( (and probably not on Macs,
> either), as canonpath flips the '/' back to the native
> directory separator ('\' on Win32). What one could do is
> then s{[\\:]}{/}g afterwards, but on Win32 one has to take
> care of the case that the drive is specified, as
> D:/whatever, and not change the ':'. The following is OK:

Sorry, I didn't know that. Does this work?

sub t_catfile_unix {
     my $f = File::Spec::Unix->canonpath(join "/", @_);
     return $f unless File::Spec->file_name_is_absolute($f);
     return Apache::TestConfig::WIN32 ?
         Win32::GetLongPathName($f) : $f;
}

I guess if we do that than your very original patch is just right. We came a 
full cirle back to where we started (thanks to me ;).

So may be just go with:

   my $f = File::Spec::Unix->catfile(@_);

One more thing, I'm not sure about. File::Spec has a clear separation between 
path and file/dir, the former optionally includes the drive/volume 
information, the latter do not. Does Win32::GetLongPathName($f) return a path 
(including drive/volume) or just dir/file? i.e. t_catfile* should deal only 
with dir/file and not path?

Or am I wrong and it's file/path vs. dir? It just makes no difference on Unix, 
so I'm a bit confused here.

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Mime
View raw message