Jos I. Boumans wrote:
On 03 Oct 2007, at 02:53, John E. Malmberg wrote:
Jos I. Boumans wrote:
On 02 Oct 2007, at 14:49, John E. Malmberg wrote:
After encountering this again in the Module Build tests, I think
it may be better to let VMS:::Filespec::vmsify do the translation,
as it knows when to change the dots to underscores.
I like this idea, and it's not hard to implement generically in
C::I::Utils->_safe_path,
where we do pathname fixes for Win32 already.
One question though:
It is a three step procedure:
1. Make sure that the value to be converted, $pkg_namver is in
UNIX directory syntax by appending a '/' to it.
2. Use VMS::Filespec::vmsify($pkg_namver . '/') to convert the
dots to underscores if needed. The trailing '/' is needed as so
that C<vmsify> knows that it should use directory translation
instead of filename translation, as filename translation leaves
one dot.
3. Use
if ($^O eq 'VMS') {
my @dirs =
File::Spec->splitdir(VMS::Filespec::vmsify($pkg_namver . '/')
$pkg_namver = $dirs[0];
}
splitdir() returns an array -- from a generic path, being either /
dir/ or /dir/file, what would
be the right way to get the 'proper' path back? Do we use catfile()?
In this case we know that we called splitdir on a single directory,
so the first and only element of the returned array is the value that
we want, as per the updated sample above.
In this case it's a single directory yes, but i've generalized it to
'fix unsafe paths' on VMS.
What would be the proper way to reconstruct the path after the '/'
trick on VMS?
File::Spec->catdir will put the path back together.
The '/' trick only works if the string is a directory name with UNIX
style directory delimiters or no directory delimiters. It is to force
vmsify to treat the input specification as UNIX.
There is a VMS::Filespec::unixpath() to do the appending of the '/' to
the specification, which will do a VMS::Filespec::vmsify() if needed.
However it is not a good idea to call vmsify() on a pathname returned by
unixify(), and it is not a good idea to call unixify() on a pathname
returned by vmsify(). Because of the nature of the conversion, not all
file specifications can make the round trip.
I think that directory specifications can safely make the round trip,
but not ones containing filenames.
-John
[EMAIL PROTECTED]
Personal Opinion Only