package File::Basename;
use re 'taint';
require Exporter;
@ISA=qw(Exporter);
@EXPORT=qw(fileparse fileparse_set_fstype basename dirname);
use vars qw($VERSION $Fileparse_fstype $Fileparse_igncase);
$VERSION = "2.6";
sub fileparse_set_fstype{my@old=($Fileparse_fstype,$Fileparse_igncase);
if(@_){$Fileparse_fstype=$_[0];
$Fileparse_igncase=($_[0]=~/^(?:MacOS|VMS|AmigaOS|os2|RISCOS|MSWin32|MSDOS)/i);}wantarray?@old:$old[0];}sub fileparse{my($fullname,@suffices)=@_;
my($fstype,$igncase)=($Fileparse_fstype,$Fileparse_igncase);
my($dirpath,$tail,$suffix,$basename);
my($taint)=substr($fullname,0,0);
if($fstype=~/^VMS/i){if($fullname=~m#/#){$fstype=''}else{($dirpath,$basename)=($fullname=~/^(.*[:>\]])?(.*)/);
$dirpath||='';}}if($fstype=~/^MS(DOS|Win32)/i){($dirpath,$basename)=($fullname=~/^((?:.*[:\\\/])?)(.*)/);
$dirpath.='.\\' unless$dirpath=~/[\\\/]$/;}elsif($fstype=~/^MacOS/i){($dirpath,$basename)=($fullname=~/^(.*:)?(.*)/);}elsif($fstype=~/^AmigaOS/i){($dirpath,$basename)=($fullname=~/(.*[:\/])?(.*)/);
$dirpath='./' unless$dirpath;}elsif($fstype!~/^VMS/i){($dirpath,$basename)=($fullname=~m#^(.*/)?(.*)#);
if($^O eq 'VMS' and$fullname=~m:/[^/]+/000000/?:){($basename,$dirpath)=('',$fullname);}$dirpath='./' unless$dirpath;}if(@suffices){$tail='';
foreach$suffix(@suffices){my$pat=($igncase?'(?i)':'')."($suffix)\$";
if($basename=~s/$pat//){$taint.=substr($suffix,0,0);
$tail=$1.$tail;}}}$tail.=$taint if defined$tail;
wantarray?($basename.$taint,$dirpath.$taint,$tail):$basename.$taint;}sub basename{my($name)=shift;
(fileparse($name,map("\Q$_\E",@_)))[0];}sub dirname{my($basename,$dirname)=fileparse($_[0]);
my($fstype)=$Fileparse_fstype;
if($fstype=~/VMS/i){if($_[0]=~m#/#){$fstype=''}else{return$dirname||$ENV{DEFAULT}}}if($fstype=~/MacOS/i){return$dirname}elsif($fstype=~/MSDOS/i){$dirname=~s/([^:])[\\\/]*$/$1/;
unless(length($basename)){($basename,$dirname)=fileparse$dirname; $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;
$dirname=~s#[^:/]+$## unless length($basename);}else{$dirname=~s:(.)/*$:$1:;
unless(length($basename)){local($File::Basename::Fileparse_fstype)=$fstype;
($basename,$dirname)=fileparse$dirname; $dirname=~s:(.)/*$:$1:;}}$dirname;}fileparse_set_fstype$^O; 1;
