1N/AFile::Spec::Win32 - methods for Win32 file specs 1N/A require File::Spec::Win32; # Done internally by File::Spec if needed 1N/ASee File::Spec::Unix for a documentation of the methods provided 1N/Athere. This package overrides the implementation of these methods, not 1N/AReturns a string representation of the null device. 1N/AReturns a string representation of the first existing directory 1N/Afrom the following list: 1N/AThe SYS:/temp is preferred in Novell NetWare (the File::Spec::Win32 1N/Ais used also for NetWare). 1N/ASince Perl 5.8.0, if running under taint mode, and if the environment 1N/Avariables are tainted, they are not used. 1N/A return scalar($
file =~ m{^([a-z]:)?[\\/]}
is);
1N/AConcatenate one or more directory names and a filename to form a 1N/Acomplete path ending with a filename 1N/A # append a backslash to each argument unless it has one there 1N/A $_ .=
"\\" unless m{\\$};
1N/A foreach (@
path) { $_ =
'.' if $_
eq '' }
1N/ANo physical check on the filesystem, but a logical cleanup of a 1N/Apath. On UNIX eliminated successive slashes and successive "/.". 1N/A dir1\dir2\dir3\..\..\dir4 -> \dir\dir4 and even 1N/A dir1\dir2\dir3\...\dir4 -> \dir\dir4 1N/A $
path =~ s|([^\\])\\+|$
1\\|g;
# xx\\\\xx -> xx\xx 1N/A $
path =~ s|(\\\.)+\\|\\|g;
# xx\.\.\xx -> xx\xx 1N/A $
path =~ s|^(\.\\)+||s
unless $
path eq ".\\";
# .\xx -> xx 1N/A unless $
path =~ m{^([A-Z]:)?\\\Z(?!\n)}s;
# xx\ -> xx 1N/A $
path =~ s|\\\.\.\.\\|\\\.\.\\\.\.\\|g;
# \...\ is 2 levels up 1N/A $
path =~ s|^\.\.\.\\|\.\.\\\.\.\\|g;
# ...\ is 2 levels up 1N/A return $
path if $
path =~ m|^\.\.|;
# skip relative paths 1N/A return $
path unless $
path =~ /\.\./;
# too few .'s to cleanup 1N/A return $
path if $
path =~ /\.\.\.\./;
# too many .'s to cleanup 1N/A $
path =~ s{^\\\.\.$}{\\};
# \.. -> \ 1N/A 1 while $
path =~ s{^\\\.\.}{};
# \..\xx -> \xx 1N/A # for each .. in @path_dirs pop one item from 1N/A ($volume,$directories,$file) = File::Spec->splitpath( $path ); 1N/A ($volume,$directories,$file) = File::Spec->splitpath( $path, $no_file ); 1N/ASplits a path into volume, directory, and filename portions. Assumes that 1N/Athe last file is a path unless the path ends in '\\', '\\.', '\\..' 1N/Aor $no_file is true. On Win32 this means that $no_file true makes this return 1N/A( $volume, $path, '' ). 1N/ASeparators accepted are \ and /. 1N/AVolumes can be drive letters or UNC sharenames (\\server\share). 1N/AThe results can be passed to L</catpath> to get back a path equivalent to 1N/A(usually identical to) the original path. 1N/A m{^( (?:[a-
zA-Z]:|(?:\\\\|//)[^\\/]+[\\/][^\\/]+)? )
1N/A (?:\\\\|//)[^\\/]+[\\/][^\\/]+
1N/A ( (?:.*[\\\\/](?:\.\.?\Z(?!\n))?)? )
1N/A @dirs = File::Spec->splitdir( $directories ); 1N/A$directories must be only the directory portion of the path on systems 1N/Athat have the concept of a volume or that have path syntax that differentiates 1N/Afiles from directories. 1N/AUnlike just splitting the directories on the separator, leading empty and 1N/Atrailing directory entries can be returned, because these are significant 1N/A File::Spec->splitdir( "/a/b/c" ); 1N/A ( '', 'a', 'b', '', 'c', '' ) 1N/A # split() likes to forget about trailing null fields, so here we 1N/A # check to be sure that there will not be any before handling the 1N/A # since there was a trailing separator, add a file name to the end, 1N/A # then do the split, then replace it with ''. 1N/ATakes volume, directory and file portions and returns an entire path. Under 1N/AUnix, $volume is ignored, and this is just like catfile(). On other OSs, 1N/Athe $volume become significant. 1N/A # If it's UNC, make sure the glue separator is there, reusing 1N/A # whatever separator is first in the $volume 1N/A if ( $
volume =~ m@^([\\/])[\\/][^\\/]+[\\/][^\\/]+\Z(?!\n)@s &&
1N/A # If the volume is not just A:, make sure the glue separator is 1N/A # there, reusing whatever separator is first in the $volume if possible. 1N/A # Can't relativize across volumes 1N/A # Now, remove all leading components that are the same 1N/A=head2 Note For File::Spec::Win32 Maintainers 1N/ANovell NetWare inherits its File::Spec behaviour from File::Spec::Win32. 1N/ASee L<File::Spec> and L<File::Spec::Unix>. This package overrides the 1N/Aimplementation of these methods, not the semantics.