You select the syntax via the routine fileparse_set_fstype().
If the argument passed to it contains one of the substrings
-"VMS", "MSDOS", "MacOS", or "AmigaOS", the file specification
+"VMS", "MSDOS", "MacOS", "AmigaOS" or "MSWin32", the file specification
syntax of that operating system is used in future calls to
fileparse(), basename(), and dirname(). If it contains none of
these substrings, UNIX syntax is used. This pattern matching is
rules instead, for that function call only.
If the argument passed to it contains one of the substrings "VMS",
-"MSDOS", "MacOS", "AmigaOS", "os2", or "RISCOS", then the pattern
+"MSDOS", "MacOS", "AmigaOS", "os2", "MSWin32" or "RISCOS", then the pattern
matching for suffix removal is performed without regard for case,
since those systems are not case-sensitive when opening existing files
(though some of them preserve case on file creation).
@EXPORT = qw(fileparse fileparse_set_fstype basename dirname);
#use strict;
#use vars qw($VERSION $Fileparse_fstype $Fileparse_igncase);
-$VERSION = "2.4";
+$VERSION = "2.5";
# fileparse_set_fstype() - specify OS-based rules used in future
my @old = ($Fileparse_fstype, $Fileparse_igncase);
if (@_) {
$Fileparse_fstype = $_[0];
- $Fileparse_igncase = ($_[0] =~ /^(?:MacOS|VMS|AmigaOS|os2|RISCOS)/i);
+ $Fileparse_igncase = ($_[0] =~ /^(?:MacOS|VMS|AmigaOS|os2|RISCOS|MSWin32)/i);
}
wantarray ? @old : $old[0];
}
($dirpath,$basename) = ($fullname =~ /^(.*[:>\]])?(.*)/);
}
}
- if ($fstype =~ /^MSDOS/i) {
- ($dirpath,$basename) = ($fullname =~ /^(.*[:\\\/])?(.*)/);
+ if ($fstype =~ /^MS(DOS|Win32)/i) {
+ ($dirpath,$basename) = ($fullname =~ /^((?:.*[:\\\/])?)(.*)/);
$dirpath .= '.\\' unless $dirpath =~ /[\\\/]$/;
}
elsif ($fstype =~ /^MacOS/i) {
$dirname =~ s/([^:])[\\\/]*$/$1/;
}
}
+ elsif ($fstype =~ /MSWin32/i) {
+ $dirname =~ s/([^:])[\\\/]*$/$1/;
+ unless( length($basename) ) {
+ ($basename,$dirname) = fileparse $dirname;
+ $dirname =~ s/([^:])[\\\/]*$/$1/;
+ }
+ }
elsif ($fstype =~ /AmigaOS/i) {
if ( $dirname =~ /:$/) { return $dirname }
chop $dirname;