summaryrefslogtreecommitdiff
path: root/lib/File
diff options
context:
space:
mode:
authorDave Rolsky <autarch@urth.org>2001-12-24 07:27:23 -0600
committerJarkko Hietaniemi <jhi@iki.fi>2001-12-24 22:58:18 +0000
commitecf68df6e17568faac489c8f52d98e01e32472af (patch)
tree9cc6067e7520f3d3040c2bc3759cf5a94f024a8b /lib/File
parente036fef9c83c3a56ef6c3a3bedfa658fcb8a2517 (diff)
downloadperl-ecf68df6e17568faac489c8f52d98e01e32472af.tar.gz
: ExtUtils::MM_* and File::Spec
Message-ID: <Pine.LNX.4.43.0112241305020.21723-100000@urth.org> p4raw-id: //depot/perl@13880
Diffstat (limited to 'lib/File')
-rw-r--r--lib/File/Spec.pm12
-rw-r--r--lib/File/Spec/Cygwin.pm35
-rw-r--r--lib/File/Spec/NW5.pm48
-rw-r--r--lib/File/Spec/Win32.pm8
4 files changed, 98 insertions, 5 deletions
diff --git a/lib/File/Spec.pm b/lib/File/Spec.pm
index f177f68831..9d9d5b676e 100644
--- a/lib/File/Spec.pm
+++ b/lib/File/Spec.pm
@@ -9,9 +9,19 @@ my %module = (MacOS => 'Mac',
MSWin32 => 'Win32',
os2 => 'OS2',
VMS => 'VMS',
- epoc => 'Epoc');
+ epoc => 'Epoc',
+ cygwin => 'Cygwin');
+
my $module = $module{$^O} || 'Unix';
+
+if ($^O eq 'MSWin32') {
+ require Config;
+ if ($Config::Config{osname} eq 'NetWare') {
+ $module = 'NW5';
+ }
+}
+
require "File/Spec/$module.pm";
@ISA = ("File::Spec::$module");
diff --git a/lib/File/Spec/Cygwin.pm b/lib/File/Spec/Cygwin.pm
new file mode 100644
index 0000000000..23fed18f50
--- /dev/null
+++ b/lib/File/Spec/Cygwin.pm
@@ -0,0 +1,35 @@
+package File::Spec::Cygwin;
+
+use strict;
+use vars qw(@ISA $VERSION);
+require File::Spec::Unix;
+
+$VERSION = '1.0';
+
+@ISA = qw(File::Spec::Unix);
+
+sub canonpath {
+ my($self,$path) = @_;
+ $path =~ s|\\|/|g;
+ return $self->SUPER::canonpath($path);
+}
+
+1;
+__END__
+
+=head1 NAME
+
+File::Spec::Cygwin - methods for Cygwin file specs
+
+=head1 SYNOPSIS
+
+ require File::Spec::Cygwin; # Done internally by File::Spec if needed
+
+=head1 DESCRIPTION
+
+See File::Spec::Unix for a documentation of the methods provided
+there. This package overrides the implementation of these methods, not
+the semantics.
+
+This module is still in beta. Cygwin-knowledgeable folks are invited
+to offer patches and suggestions.
diff --git a/lib/File/Spec/NW5.pm b/lib/File/Spec/NW5.pm
new file mode 100644
index 0000000000..772a93df56
--- /dev/null
+++ b/lib/File/Spec/NW5.pm
@@ -0,0 +1,48 @@
+package File::Spec::NW5;
+
+use strict;
+use vars qw(@ISA $VERSION);
+require File::Spec::Win32;
+
+$VERSION = '1.0';
+
+@ISA = qw(File::Spec::Win32);
+
+sub catdir {
+ my $self = shift;
+ my @args = @_;
+ for (@args) {
+ # append a slash to each argument unless it has one there
+ $_ .= "\\" if $_ eq '' or substr($_,-1) ne "\\";
+ }
+ my $result = $self->canonpath(join('', @args));
+ $result;
+}
+
+sub canonpath {
+ my $self = shift;
+ my $path = $self->SUPER::canonpath(@_);
+ $path .= '.' if $path =~ m#\\$#;
+ return $path;
+}
+
+
+1;
+__END__
+
+=head1 NAME
+
+File::Spec::NW5 - methods for NetWare file specs
+
+=head1 SYNOPSIS
+
+ require File::Spec::NW5; # Done internally by File::Spec if needed
+
+=head1 DESCRIPTION
+
+See File::Spec::Win32 and File::Spec::Unix for a documentation of the
+methods provided there. This package overrides the implementation of
+these methods, not the semantics.
+
+This module is still in beta. NetWare-knowledgeable folks are invited
+to offer patches and suggestions.
diff --git a/lib/File/Spec/Win32.pm b/lib/File/Spec/Win32.pm
index ceebb2d100..c2e463b80c 100644
--- a/lib/File/Spec/Win32.pm
+++ b/lib/File/Spec/Win32.pm
@@ -117,11 +117,11 @@ sub canonpath {
my ($self,$path) = @_;
$path =~ s/^([a-z]:)/\u$1/s;
$path =~ s|/|\\|g;
- $path =~ s|([^\\])\\+|$1\\|g; # xx////xx -> xx/xx
- $path =~ s|(\\\.)+\\|\\|g; # xx/././xx -> xx/xx
- $path =~ s|^(\.\\)+||s unless $path eq ".\\"; # ./xx -> xx
+ $path =~ s|([^\\])\\+|$1\\|g; # xx\\\\xx -> xx\xx
+ $path =~ s|(\\\.)+\\|\\|g; # xx\.\.\xx -> xx\xx
+ $path =~ s|^(\.\\)+||s unless $path eq ".\\"; # .\xx -> xx
$path =~ s|\\\Z(?!\n)||
- unless $path =~ m#^([A-Z]:)?\\\Z(?!\n)#s; # xx/ -> xx
+ unless $path =~ m#^([A-Z]:)?\\\Z(?!\n)#s; # xx\ -> xx
return $path;
}