Big5HKSCS
view release on metacpan or search on metacpan
lib/Ebig5hkscs.pm view on Meta::CPAN
return CORE::chdir $dir;
}
elsif (($] =~ /^(?:5\.006|5\.008000)/oxms) and ($^O eq 'MSWin32')) {
local $@;
my $chdir = CORE::eval q{
CORE::require 'jacode.pl';
# P.676 ${^WIDE_SYSTEM_CALLS}
# in Chapter 28: Special Names
# of ISBN 0-596-00027-8 Programming Perl Third Edition.
# P.790 ${^WIDE_SYSTEM_CALLS}
# in Chapter 25: Special Names
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
local ${^WIDE_SYSTEM_CALLS} = 1;
return CORE::chdir jcode::utf8($dir,'sjis');
};
if (not $@) {
return $chdir;
}
}
# old idea (Win32 module required)
elsif (0) {
local $@;
my $shortdir = '';
my $chdir = CORE::eval q{
use Win32;
$shortdir = Win32::GetShortPathName($dir);
if ($shortdir ne $dir) {
return CORE::chdir $shortdir;
}
else {
return 0;
}
};
if ($@) {
my @char = $dir =~ /\G (?>$q_char) /oxmsg;
while ($char[-1] eq "\x5C") {
pop @char;
}
$dir = join '', @char;
croak "Perl$] can't chdir to $dir (chr(0x5C) ended path), Win32.pm module may help you";
}
elsif ($shortdir eq $dir) {
my @char = $dir =~ /\G (?>$q_char) /oxmsg;
while ($char[-1] eq "\x5C") {
pop @char;
}
$dir = join '', @char;
croak "Perl$] can't chdir to $dir (chr(0x5C) ended path)";
}
return $chdir;
}
# rejected idea ...
elsif (0) {
# MSDN SetCurrentDirectory function
# http://msdn.microsoft.com/ja-jp/library/windows/desktop/aa365530(v=vs.85).aspx
#
# Data Execution Prevention (DEP)
# http://vlaurie.com/computers2/Articles/dep.htm
#
# Learning x86 assembler with Perl -- Shibuya.pm#11
# http://developer.cybozu.co.jp/takesako/2009/06/perl-x86-shibuy.html
#
# Introduction to Win32::API programming in Perl
# http://d.hatena.ne.jp/TAKESAKO/20090324/1237879559
#
# DynaLoader - Dynamically load C libraries into Perl code
# http://perldoc.perl.org/DynaLoader.html
#
# Basic knowledge of DynaLoader
# http://blog.64p.org/entry/20090313/1236934042
if (($] =~ /^5\.006/oxms) and
($^O eq 'MSWin32') and
($ENV{'PROCESSOR_ARCHITECTURE'} eq 'x86') and
CORE::eval(q{CORE::require 'Dyna'.'Loader'})
) {
my $x86 = join('',
# PUSH Iv
"\x68", pack('P', "$dir\\\0"),
# MOV eAX, Iv
"\xb8", pack('L',
*{'Dyna'.'Loader::dl_find_symbol'}{'CODE'}->(
*{'Dyna'.'Loader::dl_load_file'}{'CODE'}->("$ENV{'SystemRoot'}\\system32\\kernel32.dll"),
'SetCurrentDirectoryA'
)
),
# CALL eAX
"\xff\xd0",
# RETN
"\xc3",
);
*{'Dyna'.'Loader::dl_install_xsub'}{'CODE'}->('_SetCurrentDirectoryA', unpack('L', pack 'P', $x86));
_SetCurrentDirectoryA();
chomp(my $chdir = qx{chdir});
if (Ebig5hkscs::fc($chdir) eq Ebig5hkscs::fc($dir)) {
return 1;
}
else {
return 0;
}
}
}
# COMMAND.COM's unhelpful tips:
# Displays a list of files and subdirectories in a directory.
# http://www.lagmonster.org/docs/DOS7/z-dir.html
#
# Syntax:
#
# DIR [drive:] [path] [filename] [/Switches]
#
( run in 1.522 second using v1.01-cache-2.11-cpan-63c85eba8c4 )