⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vms.pm

📁 source of perl for linux application,
💻 PM
📖 第 1 页 / 共 2 页
字号:
    $dirspec =~ s/\[000000\./\[/g;		# [000000.	==> [    $dirspec =~ s/\.\]\[000000\]/\]/g;		# .][000000]	==> ]    $dirspec =~ s/\.\]\[/\./g;			# foo.][bar	==> foo.bar    while ($dirspec =~ s/(^|[\[\<\.])\-(\-+)($|[\]\>\.])/$1-.$2$3/g) {}						# That loop does the following						# with any amount of dashes:						# .--.		==> .-.-.						# [--.		==> [-.-.						# .--]		==> .-.-]						# [--]		==> [-.-]    $dirspec = "[$dirspec]" unless $dirspec =~ /[\[<]/; # make legal    $dirspec =~ s/^(\[|<)\./$1/;    @dirs = split /(?<!\^)\./, vmspath($dirspec);    $dirs[0] =~ s/^[\[<]//s;  $dirs[-1] =~ s/[\]>]\Z(?!\n)//s;    @dirs;}=item catpath (override)Construct a complete filespec using VMS syntax=cutsub catpath {    my($self,$dev,$dir,$file) = @_;        # We look for a volume in $dev, then in $dir, but not both    my ($dir_volume, $dir_dir, $dir_file) = $self->splitpath($dir);    $dev = $dir_volume unless length $dev;    $dir = length $dir_file ? $self->catfile($dir_dir, $dir_file) : $dir_dir;        if ($dev =~ m|^/+([^/]+)|) { $dev = "$1:"; }    else { $dev .= ':' unless $dev eq '' or $dev =~ /:\Z(?!\n)/; }    if (length($dev) or length($dir)) {      $dir = "[$dir]" unless $dir =~ /[\[<\/]/;      $dir = vmspath($dir);    }    "$dev$dir$file";}=item abs2rel (override)Use VMS syntax when converting filespecs.=cutsub abs2rel {    my $self = shift;    return vmspath(File::Spec::Unix::abs2rel( $self, @_ ))        if grep m{/}, @_;    my($path,$base) = @_;    $base = $self->_cwd() unless defined $base and length $base;    for ($path, $base) { $_ = $self->canonpath($_) }    # Are we even starting $path on the same (node::)device as $base?  Note that    # logical paths or nodename differences may be on the "same device"     # but the comparison that ignores device differences so as to concatenate     # [---] up directory specs is not even a good idea in cases where there is     # a logical path difference between $path and $base nodename and/or device.    # Hence we fall back to returning the absolute $path spec    # if there is a case blind device (or node) difference of any sort    # and we do not even try to call $parse() or consult %ENV for $trnlnm()    # (this module needs to run on non VMS platforms after all).        my ($path_volume, $path_directories, $path_file) = $self->splitpath($path);    my ($base_volume, $base_directories, $base_file) = $self->splitpath($base);    return $path unless lc($path_volume) eq lc($base_volume);    for ($path, $base) { $_ = $self->rel2abs($_) }    # Now, remove all leading components that are the same    my @pathchunks = $self->splitdir( $path_directories );    my $pathchunks = @pathchunks;    unshift(@pathchunks,'000000') unless $pathchunks[0] eq '000000';    my @basechunks = $self->splitdir( $base_directories );    my $basechunks = @basechunks;    unshift(@basechunks,'000000') unless $basechunks[0] eq '000000';    while ( @pathchunks &&             @basechunks &&             lc( $pathchunks[0] ) eq lc( $basechunks[0] )           ) {        shift @pathchunks ;        shift @basechunks ;    }    # @basechunks now contains the directories to climb out of,    # @pathchunks now has the directories to descend in to.    if ((@basechunks > 0) || ($basechunks != $pathchunks)) {      $path_directories = join '.', ('-' x @basechunks, @pathchunks) ;    }    else {      $path_directories = join '.', @pathchunks;    }    $path_directories = '['.$path_directories.']';    return $self->canonpath( $self->catpath( '', $path_directories, $path_file ) ) ;}=item rel2abs (override)Use VMS syntax when converting filespecs.=cutsub rel2abs {    my $self = shift ;    my ($path,$base ) = @_;    return undef unless defined $path;    if ($path =~ m/\//) {	$path = ( -d $path || $path =~ m/\/\z/  # educated guessing about		   ? vmspath($path)             # whether it's a directory		   : vmsify($path) );    }    $base = vmspath($base) if defined $base && $base =~ m/\//;    # Clean up and split up $path    if ( ! $self->file_name_is_absolute( $path ) ) {        # Figure out the effective $base and clean it up.        if ( !defined( $base ) || $base eq '' ) {            $base = $self->_cwd;        }        elsif ( ! $self->file_name_is_absolute( $base ) ) {            $base = $self->rel2abs( $base ) ;        }        else {            $base = $self->canonpath( $base ) ;        }        # Split up paths        my ( $path_directories, $path_file ) =            ($self->splitpath( $path ))[1,2] ;        my ( $base_volume, $base_directories ) =            $self->splitpath( $base ) ;        $path_directories = '' if $path_directories eq '[]' ||                                  $path_directories eq '<>';        my $sep = '' ;        $sep = '.'            if ( $base_directories =~ m{[^.\]>]\Z(?!\n)} &&                 $path_directories =~ m{^[^.\[<]}s            ) ;        $base_directories = "$base_directories$sep$path_directories";        $base_directories =~ s{\.?[\]>][\[<]\.?}{.};        $path = $self->catpath( $base_volume, $base_directories, $path_file );   }    return $self->canonpath( $path ) ;}# eliminate_macros() and fixpath() are MakeMaker-specific methods# which are used inside catfile() and catdir().  MakeMaker has its own# copies as of 6.06_03 which are the canonical ones.  We leave these# here, in peace, so that File::Spec continues to work with MakeMakers# prior to 6.06_03.# # Please consider these two methods deprecated.  Do not patch them,# patch the ones in ExtUtils::MM_VMS instead.sub eliminate_macros {    my($self,$path) = @_;    return '' unless (defined $path) && ($path ne '');    $self = {} unless ref $self;    if ($path =~ /\s/) {      return join ' ', map { $self->eliminate_macros($_) } split /\s+/, $path;    }    my($npath) = unixify($path);    my($complex) = 0;    my($head,$macro,$tail);    # perform m##g in scalar context so it acts as an iterator    while ($npath =~ m#(.*?)\$\((\S+?)\)(.*)#gs) {         if ($self->{$2}) {            ($head,$macro,$tail) = ($1,$2,$3);            if (ref $self->{$macro}) {                if (ref $self->{$macro} eq 'ARRAY') {                    $macro = join ' ', @{$self->{$macro}};                }                else {                    print "Note: can't expand macro \$($macro) containing ",ref($self->{$macro}),                          "\n\t(using MMK-specific deferred substitutuon; MMS will break)\n";                    $macro = "\cB$macro\cB";                    $complex = 1;                }            }            else { ($macro = unixify($self->{$macro})) =~ s#/\Z(?!\n)##; }            $npath = "$head$macro$tail";        }    }    if ($complex) { $npath =~ s#\cB(.*?)\cB#\${$1}#gs; }    $npath;}# Deprecated.  See the note above for eliminate_macros().sub fixpath {    my($self,$path,$force_path) = @_;    return '' unless $path;    $self = bless {} unless ref $self;    my($fixedpath,$prefix,$name);    if ($path =~ /\s/) {      return join ' ',             map { $self->fixpath($_,$force_path) }	     split /\s+/, $path;    }    if ($path =~ m#^\$\([^\)]+\)\Z(?!\n)#s || $path =~ m#[/:>\]]#) {         if ($force_path or $path =~ /(?:DIR\)|\])\Z(?!\n)/) {            $fixedpath = vmspath($self->eliminate_macros($path));        }        else {            $fixedpath = vmsify($self->eliminate_macros($path));        }    }    elsif ((($prefix,$name) = ($path =~ m#^\$\(([^\)]+)\)(.+)#s)) && $self->{$prefix}) {        my($vmspre) = $self->eliminate_macros("\$($prefix)");        # is it a dir or just a name?        $vmspre = ($vmspre =~ m|/| or $prefix =~ /DIR\Z(?!\n)/) ? vmspath($vmspre) : '';        $fixedpath = ($vmspre ? $vmspre : $self->{$prefix}) . $name;        $fixedpath = vmspath($fixedpath) if $force_path;    }    else {        $fixedpath = $path;        $fixedpath = vmspath($fixedpath) if $force_path;    }    # No hints, so we try to guess    if (!defined($force_path) and $fixedpath !~ /[:>(.\]]/) {        $fixedpath = vmspath($fixedpath) if -d $fixedpath;    }    # Trim off root dirname if it's had other dirs inserted in front of it.    $fixedpath =~ s/\.000000([\]>])/$1/;    # Special case for VMS absolute directory specs: these will have had device    # prepended during trip through Unix syntax in eliminate_macros(), since    # Unix syntax has no way to express "absolute from the top of this device's    # directory tree".    if ($path =~ /^[\[>][^.\-]/) { $fixedpath =~ s/^[^\[<]+//; }    $fixedpath;}=back=head1 COPYRIGHTCopyright (c) 2004 by the Perl 5 Porters.  All rights reserved.This program is free software; you can redistribute it and/or modifyit under the same terms as Perl itself.=head1 SEE ALSOSee L<File::Spec> and L<File::Spec::Unix>.  This package overrides theimplementation of these methods, not the semantics.An explanation of VMS file specs can be found atL<"http://h71000.www7.hp.com/doc/731FINAL/4506/4506pro_014.html#apps_locating_naming_files">.=cut1;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -