Big5
view release on metacpan or search on metacpan
lib/Ebig5.pm view on Meta::CPAN
$path .= '/';
my @subpath = ();
while ($path =~ /
((?: [^\x81-\xFE\/\\]|[\x81-\xFE][\x00-\xFF] )+?) [\/\\]
/oxmsg
) {
push @subpath, $1;
}
my $tail = pop @subpath;
my $head = join $pathsep, @subpath;
return $head, $tail;
}
#
# via File::HomeDir::Windows 1.00
#
sub my_home_MSWin32 {
# A lot of unix people and unix-derived tools rely on
# the ability to overload HOME. We will support it too
# so that they can replace raw HOME calls with File::HomeDir.
if (exists $ENV{'HOME'} and $ENV{'HOME'}) {
return $ENV{'HOME'};
}
# Do we have a user profile?
elsif (exists $ENV{'USERPROFILE'} and $ENV{'USERPROFILE'}) {
return $ENV{'USERPROFILE'};
}
# Some Windows use something like $ENV{'HOME'}
elsif (exists $ENV{'HOMEDRIVE'} and exists $ENV{'HOMEPATH'} and $ENV{'HOMEDRIVE'} and $ENV{'HOMEPATH'}) {
return join '', $ENV{'HOMEDRIVE'}, $ENV{'HOMEPATH'};
}
return undef;
}
#
# via File::HomeDir::Unix 1.00
#
sub my_home {
my $home;
if (exists $ENV{'HOME'} and defined $ENV{'HOME'}) {
$home = $ENV{'HOME'};
}
# This is from the original code, but I'm guessing
# it means "login directory" and exists on some Unixes.
elsif (exists $ENV{'LOGDIR'} and $ENV{'LOGDIR'}) {
$home = $ENV{'LOGDIR'};
}
### More-desperate methods
# Light desperation on any (Unixish) platform
else {
$home = CORE::eval q{ (getpwuid($<))[7] };
}
# On Unix in general, a non-existant home means "no home"
# For example, "nobody"-like users might use /nonexistant
if (defined $home and ! Ebig5::d($home)) {
$home = undef;
}
return $home;
}
#
# Big5 file lstat (with parameter)
#
sub Ebig5::lstat(*) {
local $_ = shift if @_;
if (-e $_) {
return CORE::lstat _;
}
elsif (_MSWin32_5Cended_path($_)) {
# Even if ${^WIN32_SLOPPY_STAT} is set to a true value, Ebig5::lstat()
# on Windows opens the file for the path which has 5c at end.
# (and so on)
local *MUST_BE_BAREWORD_AT_HERE;
if (CORE::open(MUST_BE_BAREWORD_AT_HERE, $_)) {
if (wantarray) {
my @stat = CORE::stat MUST_BE_BAREWORD_AT_HERE; # not CORE::lstat
close(MUST_BE_BAREWORD_AT_HERE) or die "Can't close file: $_: $!";
return @stat;
}
else {
my $stat = CORE::stat MUST_BE_BAREWORD_AT_HERE; # not CORE::lstat
close(MUST_BE_BAREWORD_AT_HERE) or die "Can't close file: $_: $!";
return $stat;
}
}
}
return wantarray ? () : undef;
}
#
# Big5 file lstat (without parameter)
#
sub Ebig5::lstat_() {
if (-e $_) {
return CORE::lstat _;
}
elsif (_MSWin32_5Cended_path($_)) {
local *MUST_BE_BAREWORD_AT_HERE;
if (CORE::open(MUST_BE_BAREWORD_AT_HERE, $_)) {
if (wantarray) {
my @stat = CORE::stat MUST_BE_BAREWORD_AT_HERE; # not CORE::lstat
close(MUST_BE_BAREWORD_AT_HERE) or die "Can't close file: $_: $!";
return @stat;
}
else {
( run in 1.864 second using v1.01-cache-2.11-cpan-75ffa21a3d4 )