NAME

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

SYNOPSIS

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;

DESCRIPTION

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

METHODS

new([$mode, $file_name])
my $fh = Win32::Unicode::File->new;
my $fh = Win32::Unicode::File->new($mode, $file_name); # open $file_name;
open($mode, $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+
close()
$fh->close;

close $fh;
read($buff, $len)
$fh->read(my $buff, $len) or dieW errorW;
print $buff;

read $fh, my $buff, $len;
readline()
my $line = $fh->readline;
my @line = $fh->readline;

my $line = readline $fh;
my @line = <$fh>;
print(@str)
$fh->print(@str);
print $fh @str;
printf($format, @str)
$fh->printf('[%s]', $str);
printf $fh '%d', $str;
write(@str)
$fh->write(@str);
seek($ofset, $whence)
$fh->seek(10, 1);

seek $fh, 1024, 2;
tell()
my $current = $fh->tell();

my $current = tell $fh;
slurp()
my $data = $fh->slurp;
eof()
if ($fh->eof) {
   # ...snip
}

or

if (eof $fh) {
   # ...snip
}
binmode($layer)
$fh->binmode(':encoding(cp932)')

or

binmode $fh, ':raw :utf8';

Currently available now is only the layer below.

:raw
:utf8
:encoding(foo)
error()

get error message.

$fh->error;

FUNCTIONS

unlinkW($file)

Like unlink.

unlinkW $file or dieW errorW;
copyW($from, $to)

Like File::Copy::copy.

copyW $from, $to or dieW errorW;
moveW($from, $to)

Like File::Copy::move.

moveW $from, $to or dieW errorW;
renameW($from, $to)

Alias of moveW.

touchW($file)

Like shell command touch.

touchW $file or dieW errorW;
file_type('attribute', $file_or_dir)

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
}
file_size($file)

Get file size. near -s $file

my $size = file_size $file or dieW errorW;
filename_normalize($filename)

Normalize the characters are not allowed in the file name.

my $nomalized_file_name = filename_normalize($filename);

AUTHOR

Yuji Shimada <xaicron@cpan.org>

SEE ALSO

Win32 Win32::API Win32API::File Win32::Unicode Win32::Unicode::File Win32::Unicode::Encode Win32::Unicode::Error

LICENSE

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