| 1 | # Perl hooks into the routines in vms.c for interconversion
|
|---|
| 2 | # of VMS and Unix file specification syntax.
|
|---|
| 3 | #
|
|---|
| 4 | # Version: see $VERSION below
|
|---|
| 5 | # Author: Charles Bailey [email protected]
|
|---|
| 6 | # Revised: 08-Mar-1995
|
|---|
| 7 |
|
|---|
| 8 | =head1 NAME
|
|---|
| 9 |
|
|---|
| 10 | VMS::Filespec - convert between VMS and Unix file specification syntax
|
|---|
| 11 |
|
|---|
| 12 | =head1 SYNOPSIS
|
|---|
| 13 |
|
|---|
| 14 | use VMS::Filespec;
|
|---|
| 15 | $fullspec = rmsexpand('[.VMS]file.specification'[, 'default:[file.spec]']);
|
|---|
| 16 | $vmsspec = vmsify('/my/Unix/file/specification');
|
|---|
| 17 | $unixspec = unixify('my:[VMS]file.specification');
|
|---|
| 18 | $path = pathify('my:[VMS.or.Unix.directory]specification.dir');
|
|---|
| 19 | $dirfile = fileify('my:[VMS.or.Unix.directory.specification]');
|
|---|
| 20 | $vmsdir = vmspath('my/VMS/or/Unix/directory/specification.dir');
|
|---|
| 21 | $unixdir = unixpath('my:[VMS.or.Unix.directory]specification.dir');
|
|---|
| 22 | candelete('my:[VMS.or.Unix]file.specification');
|
|---|
| 23 |
|
|---|
| 24 | =head1 DESCRIPTION
|
|---|
| 25 |
|
|---|
| 26 | This package provides routines to simplify conversion between VMS and
|
|---|
| 27 | Unix syntax when processing file specifications. This is useful when
|
|---|
| 28 | porting scripts designed to run under either OS, and also allows you
|
|---|
| 29 | to take advantage of conveniences provided by either syntax (I<e.g.>
|
|---|
| 30 | ability to easily concatenate Unix-style specifications). In
|
|---|
| 31 | addition, it provides an additional file test routine, C<candelete>,
|
|---|
| 32 | which determines whether you have delete access to a file.
|
|---|
| 33 |
|
|---|
| 34 | If you're running under VMS, the routines in this package are special,
|
|---|
| 35 | in that they're automatically made available to any Perl script,
|
|---|
| 36 | whether you're running F<miniperl> or the full F<perl>. The C<use
|
|---|
| 37 | VMS::Filespec> or C<require VMS::Filespec; import VMS::Filespec ...>
|
|---|
| 38 | statement can be used to import the function names into the current
|
|---|
| 39 | package, but they're always available if you use the fully qualified
|
|---|
| 40 | name, whether or not you've mentioned the F<.pm> file in your script.
|
|---|
| 41 | If you're running under another OS and have installed this package, it
|
|---|
| 42 | behaves like a normal Perl extension (in fact, you're using Perl
|
|---|
| 43 | substitutes to emulate the necessary VMS system calls).
|
|---|
| 44 |
|
|---|
| 45 | Each of these routines accepts a file specification in either VMS or
|
|---|
| 46 | Unix syntax, and returns the converted file specification, or C<undef>
|
|---|
| 47 | if an error occurs. The conversions are, for the most part, simply
|
|---|
| 48 | string manipulations; the routines do not check the details of syntax
|
|---|
| 49 | (e.g. that only legal characters are used). There is one exception:
|
|---|
| 50 | when running under VMS, conversions from VMS syntax use the $PARSE
|
|---|
| 51 | service to expand specifications, so illegal syntax, or a relative
|
|---|
| 52 | directory specification which extends above the tope of the current
|
|---|
| 53 | directory path (e.g [---.foo] when in dev:[dir.sub]) will cause
|
|---|
| 54 | errors. In general, any legal file specification will be converted
|
|---|
| 55 | properly, but garbage input tends to produce garbage output.
|
|---|
| 56 |
|
|---|
| 57 | Each of these routines is prototyped as taking a single scalar
|
|---|
| 58 | argument, so you can use them as unary operators in complex
|
|---|
| 59 | expressions (as long as you don't use the C<&> form of
|
|---|
| 60 | subroutine call, which bypasses prototype checking).
|
|---|
| 61 |
|
|---|
| 62 |
|
|---|
| 63 | The routines provided are:
|
|---|
| 64 |
|
|---|
| 65 | =head2 rmsexpand
|
|---|
| 66 |
|
|---|
| 67 | Uses the RMS $PARSE and $SEARCH services to expand the input
|
|---|
| 68 | specification to its fully qualified form, except that a null type
|
|---|
| 69 | or version is not added unless it was present in either the original
|
|---|
| 70 | file specification or the default specification passed to C<rmsexpand>.
|
|---|
| 71 | (If the file does not exist, the input specification is expanded as much
|
|---|
|
|---|