
Win32::Unicode::File - Unicode string file utility.

use Win32::Unicode::File;
my $file = "I \x{2665} Perl";
unlinkW $file or die $!;
copyW $from, $to or die $!;
moveW $from, $to or die $!;
file_type f => $file ? "$file is file" : "$file is not file";
my $size = file_size $file;
touchW $new_file;

Win32::Unicode::File is Unicode string file utility.

Crate a new Win32::Unicode::File instance. At the same time you can open the file to create an instance.
my $fh = Win32::Unicode::File->new; my $fh = Win32::Unicode::File->new($mode, $file_name); # create an instance and open the file
like CORE::open, but compatibility is not an argument. can not be pipe open.
$fh->open('<', $file_name) or die $!;
or
open $fh, '<', $file_name or die $!;
Be useful mode
< = r = rb > = w = wb >> = a +< = r+ +> = w+ +>> = a+
like CORE::close.
$fh->close;
or
close $fh;
Like CORE::read.
$fh->read(my $buff, $len) or die $!;
or
read $fh, my $buff, $len;
Like CORE::readline.
my $line = $fh->readline; my @line = $fh->readline;
or my $line = readline $fh; my @line = <$fh>;
Like CORE::getc.
my $char = $fh->getc;
or
my $char = getc $fh;
Data write to file.
$fh->print(@str); print $fh @str;
Formatted data write to file.
$fh->printf('[%s]', $str);
printf $fh '%d', $str;
Data write to file. alias of $fh->print
$fh->write(@str);
Like CORE::seek.
$fh->seek(10, 1);
or
seek $fh, 1024, 2;
Like CORE::tell.
my $current = $fh->tell;
or
my $current = tell $fh;
Like CORE::eof.
if ($fh->eof) {
# ...snip
}
or
if (eof $fh) {
# ...snip
}
Read all data from the file.
my $data = $fh->slurp;
$fh->binmode(':encoding(cp932)')
or
binmode $fh, ':raw :utf8';
Currently available now is only the layer below.
:raw :utf8 :encoding(foo)
Like CORE::flock
$fh->flock(2);
equals to
$fh->flock(8);
get error message.
$fh->error;
flush buffers.
$fh->flush;
enable or dsabile autoflush.
$fh->autoflush; # enable $fh->autoflush(0); # disable $fh->autoflush(1); # enable
write after flush.
$fh->printflush('foobar');
same as
$fh->print('foobar') && $fh->flush;
Like IO::File::getline.
my $line = $fh->getline;
Like IO::File::getlines.
my @$lines = $fh->getlines;
Like IO::File::getpos.
my $pos = $fh->getpos;
Like IO::File::setpos.
my $pos = $fh->setpos(10);
Returns true if the object is currentry opened file, false otherwise.
say $fh->opened ? 1 : 0;

Like CORE::unlink.
unlinkW $file or die $!;
Like File::Copy::copy.
copyW $from, $to or die $!;
Like File::Copy::move.
moveW $from, $to or die $!;
Alias of moveW.
Like shell command touch.
touchW $file or die $!;
Like CORE::stat.
my @stat = statW $file or die $!; my $stat = statW $file or die $!;
or
my $fh = Win32::Unicode::File->new(r => $file); my @stat = statW $fh or die $!; my $stat = statW $fh or die $!;
or
my @stat = statW $dir or die $!; my $stat = statW $dir or die $!;
or
my $dh = Win32::Unicode::Dir->new->open($dir); my @stat = statW $dh or die $!; my $stat = statW $dh or die $!;
If the array context, CORE:: stat like. However, scalar context case in hashref received.
Like CORE::utime.
my $rc = utime($atime, $mtime, $file, $fh);
Get windows file type
# attributes
f => file
d => directory
e => exists
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) {
# snip
}
elsif (file_type fr => $file_or_dir) { # file type 'file' and 'readonly'
# snip
}
Get file size. near -s $file
my $size = file_size $file; die $! unless defined $size;
Normalize the characters are not allowed in the file name. not export.
use Win32::Unicode::File qw(filename_normalize); my $nomalized_file_name = filename_normalize($filename);

Yuji Shimada <xaicron@cpan.org>


This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.