Chip Salzenberg > perl5.004 > VMS::Filespec

Download:
perl5.004.tar.gz

Dependencies

Annotate this POD

Related Modules

File::Spec
Inline::Files
Data::Dumper
File::Find
File::Basename
File::Path
Pod::Text
File::stat
IO::Seekable
IO::Select
more...
By perlmonks.org
Source   Latest Release: perl-5.18.2

NAME ^

VMS::Filespec - convert between VMS and Unix file specification syntax

SYNOPSIS ^

use VMS::Filespec; $fullspec = rmsexpand('[.VMS]file.specification'); $vmsspec = vmsify('/my/Unix/file/specification'); $unixspec = unixify('my:[VMS]file.specification'); $path = pathify('my:[VMS.or.Unix.directory]specification.dir'); $dirfile = fileify('my:[VMS.or.Unix.directory.specification]'); $vmsdir = vmspath('my/VMS/or/Unix/directory/specification.dir'); $unixdir = unixpath('my:[VMS.or.Unix.directory]specification.dir'); candelete('my:[VMS.or.Unix]file.specification');

DESCRIPTION ^

This package provides routines to simplify conversion between VMS and Unix syntax when processing file specifications. This is useful when porting scripts designed to run under either OS, and also allows you to take advantage of conveniences provided by either syntax (e.g. ability to easily concatenate Unix-style specifications). In addition, it provides an additional file test routine, candelete, which determines whether you have delete access to a file.

If you're running under VMS, the routines in this package are special, in that they're automatically made available to any Perl script, whether you're running miniperl or the full perl. The use VMS::Filespec or require VMS::Filespec; import VMS::Filespec ... statement can be used to import the function names into the current package, but they're always available if you use the fully qualified name, whether or not you've mentioned the .pm file in your script. If you're running under another OS and have installed this package, it behaves like a normal Perl extension (in fact, you're using Perl substitutes to emulate the necessary VMS system calls).

Each of these routines accepts a file specification in either VMS or Unix syntax, and returns the converted file specification, or undef if an error occurs. The conversions are, for the most part, simply string manipulations; the routines do not check the details of syntax (e.g. that only legal characters are used). There is one exception: when running under VMS, conversions from VMS syntax use the $PARSE service to expand specifications, so illegal syntax, or a relative directory specification which extends above the tope of the current directory path (e.g [---.foo] when in dev:[dir.sub]) will cause errors. In general, any legal file specification will be converted properly, but garbage input tends to produce garbage output.

Each of these routines is prototyped as taking a single scalar argument, so you can use them as unary operators in complex expressions (as long as you don't use the & form of subroutine call, which bypasses prototype checking).

The routines provided are:

rmsexpand

Uses the RMS $PARSE and $SEARCH services to expand the input specification to its fully qualified form. (If the file does not exist, the input specification is expanded as much as possible.) If an error occurs, returns undef and sets $! and $^E.

vmsify

Converts a file specification to VMS syntax.

unixify

Converts a file specification to Unix syntax.

pathify

Converts a directory specification to a path - that is, a string you can prepend to a file name to form a valid file specification. If the input file specification uses VMS syntax, the returned path does, too; likewise for Unix syntax (Unix paths are guaranteed to end with '/'). Note that this routine will insist that the input be a legal directory file specification; the file type and version, if specified, must be .DIR;1. For compatibility with Unix usage, the type and version may also be omitted.

fileify

Converts a directory specification to the file specification of the directory file - that is, a string you can pass to functions like stat or rmdir to manipulate the directory file. If the input directory specification uses VMS syntax, the returned file specification does, too; likewise for Unix syntax. As with pathify, the input file specification must have a type and version of .DIR;1, or the type and version must be omitted.

vmspath

Acts like pathify, but insures the returned path uses VMS syntax.

unixpath

Acts like pathify, but insures the returned path uses Unix syntax.

candelete

Determines whether you have delete access to a file. If you do, candelete returns true. If you don't, or its argument isn't a legal file specification, candelete returns FALSE. Unlike other file tests, the argument to candelete must be a file name (not a FileHandle), and, since it's an XSUB, it's a list operator, so you need to be careful about parentheses. Both of these restrictions may be removed in the future if the functionality of candelete becomes part of the Perl core.

REVISION ^

This document was last revised 22-Feb-1996, for Perl 5.002.

syntax highlighting: