# Copyright (c) 2023 Yuki Kimoto
# MIT License
class File::Basename::Instance::Win32 extends File::Basename::Instance::Unix {
version_from File::Basename;
allow File::Basename;
allow File::Basename::Instance;
use Re;
# Class Methods
private static method new : File::Basename::Instance::Win32 () {
my $self = new File::Basename::Instance::Win32;
return $self;
}
protected method fileparse : string[] ($path : string) {
unless ($path) {
die "The \$path must be defined";
}
my $dirpath = (string)undef;
my $basename = (string)undef;
if (my $match = Re->m($path, "(?s)^((?:.*[:\\\/])?)(.*)")) {
$dirpath = $match->cap1;
$basename = $match->cap2;
}
unless (Re->m($dirpath, "[\\\/]\z")) {
$dirpath .= ".\\";
}
return [$basename, $dirpath, ""];
}
protected method _strip_trailing_sep : string ($path : string) {
$path = copy $path;
Re->s((mutable string)$path, "([^:])[\\\/]*\z", method : string ($re : Regex, $match : Regex::Match) {
return $match->cap1;
});
return $path;
}
}