From: Gurusamy Sarathy Date: Tue, 23 Mar 1999 22:17:45 +0000 (+0000) Subject: File::Spec fixes from Jan Dubois X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f505c9832e74f948e2721f6c36b348502f15804c;p=p5sagit%2Fp5-mst-13.2.git File::Spec fixes from Jan Dubois Date: Sat, 06 Mar 1999 17:50:49 +0100 Message-ID: <36e25209.33833760@smtp1.ibm.net> Subject: [PATCH 5.005_56] Fixes for File::Spec::Functions.pm -- Date: Sat, 06 Mar 1999 18:15:00 +0100 Message-ID: <36e36222.37954195@smtp1.ibm.net> Subject: [PATCH 5.005_56] Fix for File::Spec::Win32.pm p4raw-id: //depot/perl@3132 --- diff --git a/MANIFEST b/MANIFEST index 62c9ccc..c413a2a 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1095,6 +1095,7 @@ t/lib/fields.t See if base/fields works t/lib/filecache.t See if FileCache works t/lib/filecopy.t See if File::Copy works t/lib/filefind.t See if File::Find works +t/lib/filefunc.t See if File::Spec::Functions works t/lib/filehand.t See if FileHandle works t/lib/filepath.t See if File::Path works t/lib/filespec.t See if File::Spec works diff --git a/lib/File/Spec/Functions.pm b/lib/File/Spec/Functions.pm index 77561ab..ffc1199 100644 --- a/lib/File/Spec/Functions.pm +++ b/lib/File/Spec/Functions.pm @@ -3,7 +3,7 @@ package File::Spec::Functions; use File::Spec; use strict; -use vars qw(@ISA @EXPORT); +use vars qw(@ISA @EXPORT @EXPORT_OK); require Exporter; @@ -14,13 +14,16 @@ require Exporter; catdir catfile curdir - devnull rootdir - tmpdir updir no_upwards file_name_is_absolute path +); + +@EXPORT_OK = qw( + devnull + tmpdir splitpath splitdir catpath @@ -28,9 +31,10 @@ require Exporter; rel2abs ); -foreach my $meth (@EXPORT) { +foreach my $meth (@EXPORT, @EXPORT_OK) { + my $sub = File::Spec->can($meth); no strict 'refs'; - *{$meth} = File::Spec->can($meth); + *{$meth} = sub {&$sub('File::Spec', @_)}; } @@ -64,13 +68,17 @@ The following functions are exported by default. catdir catfile curdir - devnull rootdir - tmpdir updir no_upwards file_name_is_absolute path + + +The following functions are exported only by request. + + devnull + tmpdir splitpath splitdir catpath diff --git a/lib/File/Spec/Win32.pm b/lib/File/Spec/Win32.pm index 0e00af7..0ea4970 100644 --- a/lib/File/Spec/Win32.pm +++ b/lib/File/Spec/Win32.pm @@ -99,7 +99,7 @@ sub canonpath { my ($self,$path,$reduce_ricochet) = @_; $path =~ s/^([a-z]:)/\u$1/; $path =~ s|/|\\|g; - $path =~ s|([^\\])\\+|\1\\|g; # xx////xx -> xx/xx + $path =~ s|([^\\])\\+|$1\\|g; # xx////xx -> xx/xx $path =~ s|(\\\.)+\\|\\|g; # xx/././xx -> xx/xx $path =~ s|^(\.\\)+|| unless $path eq ".\\"; # ./xx -> xx $path =~ s|\\$|| diff --git a/pod/perldelta.pod b/pod/perldelta.pod index 14ba3dc..2179676 100644 --- a/pod/perldelta.pod +++ b/pod/perldelta.pod @@ -307,6 +307,11 @@ Benchmark: running a, b, each for at least 5 CPU seconds... New features: "each for at least N CPU seconds...", "wallclock secs", and the "@ operations/CPU second (n=operations)". +=item Devel::Peek + +The Devel::Peek module provides access to the internal representation +of Perl variables. It is a data debugging tool for the XS programmer. + =item Fcntl More Fcntl constants added: F_SETLK64, F_SETLKW64, O_LARGEFILE for @@ -315,6 +320,27 @@ working, though, so no need to get overly excited), Free/Net/OpenBSD locking behaviour flags F_FLOCK, F_POSIX, Linux F_SHLCK, and O_ACCMODE: the mask of O_RDONLY, O_WRONLY, and O_RDWR. +=item File::Spec + +New methods have been added to the File::Spec module: devnull() returns +the name of the null device (/dev/null on UNIX) and tmpdir() the name of +the temp directory (normally /tmp on UNIX). There are now also methods +to convert between absolute and relative filenames: abs2rel() and +rel2abs(). For compatibility with operating systems that specify volume +names in file paths, the splitpath(), splitdir() and catdir() methods +have been added. + +=item File::Spec::Functions + +The new File::Spec::Functions modules provides a function interface +to the File::Spec module. Allows shorthand + + $fullname = catfile($dir1, $dir2, $file); + +instead of + + $fullname = File::Spec->catfile($dir1, $dir2, $file); + =item Math::Complex The accessor methods Re, Im, arg, abs, rho, and theta, can now also diff --git a/pod/perlmodlib.pod b/pod/perlmodlib.pod index 6295d97..2dc38df 100644 --- a/pod/perlmodlib.pod +++ b/pod/perlmodlib.pod @@ -161,6 +161,10 @@ get pathname of current working directory access to Berkeley DB +=item Devel::Peek + +data debugging tool for the XS programmer + =item Devel::SelfStubber generate stubs for a SelfLoading module @@ -261,6 +265,14 @@ traverse a file tree create or remove a series of directories +=item File::Spec + +portably perform operations on file names + +=item File::Spec::Functions + +function call interface to File::Spec module + =item File::stat by-name interface to Perl's builtin stat() functions diff --git a/t/lib/filefunc.t b/t/lib/filefunc.t new file mode 100755 index 0000000..46a1e35 --- /dev/null +++ b/t/lib/filefunc.t @@ -0,0 +1,17 @@ +#!./perl + +BEGIN { + $^O = ''; + chdir 't' if -d 't'; + unshift @INC, '../lib'; +} + +print "1..1\n"; + +use File::Spec::Functions; + +if (catfile('a','b','c') eq 'a/b/c') { + print "ok 1\n"; +} else { + print "not ok 1\n"; +}