Win32::Unicode::File.pm - Unicode string file utility.
use Win32::Unicode::File; my $file = "I \x{2665} Perl"; unlinkW $file or dieW errorW; copyW $from, $to or dieW errorW; moveW $from, $to or dieW errorW; file_type f => $file ? 'ok' : 'no file'; my $size = file_size $file; touchW $new_file;
Win32::Unicode::Dir is Unicode string file utility.
my $fh = Win32::Unicode::File->new; my $fh = Win32::Unicode::File->new($mode, $file_name); # open $file_name;
$fh->open('<', $file_name) or dieW errorW; open $fh, '<', $file_name or dieW errorW; # be useful mode < = r = rb > = w = wb >> = a +< = r+ +> = w+ +>> = a+
$fh->close; close $fh;
$fh->read(my $buff, $len) or dieW errorW; print $buff; read $fh, my $buff, $len;
my $line = $fh->readline; my @line = $fh->readline; my $line = readline $fh; my @line = <$fh>;
$fh->print(@str); print $fh @str;
$fh->printf('[%s]', $str); printf $fh '%d', $str;
$fh->write(@str);
$fh->seek(10, 1); seek $fh, 1024, 2;
my $current = $fh->tell(); my $current = tell $fh;
my $data = $fh->slurp;
if ($fh->eof) { # ...snip }
or
if (eof $fh) { # ...snip }
$fh->binmode(':encoding(cp932)')
binmode $fh, ':raw :utf8';
Currently available now is only the layer below.
:raw :utf8 :encoding(foo)
get error message.
$fh->error;
Like unlink.
unlinkW $file or dieW errorW;
Like File::Copy::copy.
copyW $from, $to or dieW errorW;
Like File::Copy::move.
moveW $from, $to or dieW errorW;
Alias of moveW.
Like shell command touch.
touchW $file or dieW errorW;
Get windows file type
# attributes f => file d => directory s => system r => readonly h => hidden a => archive n => normal t => temporary c => compressed o => offline i => not content indexed e => encrypted if (file_type d => $file_ro_dir) { # hogehoge } elsif (file_type fr => $file_or_dir) { # file type 'file' and 'readonly' # fugagufa }
Get file size. near -s $file
-s $file
my $size = file_size $file or dieW errorW;
Normalize the characters are not allowed in the file name.
my $nomalized_file_name = filename_normalize($filename);
Yuji Shimada <xaicron@cpan.org>
Win32 Win32API::File Win32::Unicode Win32::Unicode::File Win32::Unicode::Error
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Win32::Unicode, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Win32::Unicode
CPAN shell
perl -MCPAN -e shell install Win32::Unicode
For more information on module installation, please visit the detailed CPAN module installation guide.