Randy Kobes wrote: [...]
I think if one wants to grow old fast, offer to help maintain File::Spec :)
There is a better candidate, ExtUtils::MakeMaker. I wonder how old was Michael 2 years ago. ;)
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?
Win32::GetLongPathName(), if given a drive/volume, will use that, and include that in what it gives back. So, for example, I could get the long path name for something on drive D:\ by running a script on drive C:\. If no drive is specified, then the input is assumed to be on the drive the script is run on, and no drive appears in the output.
So if you have: C:\\MODPERL~1 => C:\\mod_perl-foo-1 D:\\MODPERL~1 => D:\\mod_perl-bar-1
and pass MODPERL~1 to Win32::GetLongPathName() without the drive, it will expand it as if C:\\mod_perl-foo-1 (if cwd is somewhere in C:\\) even if D:\\mod_perl-bar-1 was intended. I guess that's expected, and you better not forget to pass that drive letter... ;)
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.
+sub t_catfile {
+ my $f = catfile(@_);
+ return $f unless file_name_is_absolute($f);
+ return Apache::TestConfig::WIN32 ?
+ Win32::GetLongPathName($f) : $f;
+}
+
+sub t_catfile_apache {
+ my $f = File::Spec::Unix->catfile(@_);
+ return $f unless file_name_is_absolute($f);
+ return Apache::TestConfig::WIN32 ?
+ Win32::GetLongPathName($f) : $f;
}
+1 plus probably add an inlined comment for both explaining why there are needed, and the pod sections. i'd also add a comment that GetLongPathName requires an absolute path to work.
-my $script_file = catfile $vars->{serverroot}, 'cgi-bin', 'basic.pl';
+my $script_file = t_catfile_apache($vars->{serverroot}, 'cgi-bin', 'basic.pl');
no need for () as it's imported.
- my $script_file = catfile $vars->{serverroot}, 'cgi-bin', 'basic.pl';
+ my $script_file = t_catfile_apache($vars->{serverroot}, 'cgi-bin', 'basic.pl');
ditto
ok t_cmp(
"ok $script_file",
====================================================================
You raised a good point before about potentially
File::Spec::Unix at sometime in the future not being usable
on non-Unix; I guess this is something we'll have to watch
for. It does happen in principle - for example,
File::Spec::VMS requires VMS::Filespec, which presumably is
a VMS-specific module. However, at this point all of the
non-Unix File::Spec::* require File::Spec::Unix, so it
appears by design that File::Spec::Unix is the "base" class.
Sounds good.
So go ahead and commit the stuff... thanks Randy!
__________________________________________________________________ Stas Bekman JAm_pH ------> Just Another mod_perl Hacker http://stason.org/ mod_perl Guide ---> http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
