Win32::Unicode::Dir - Unicode string directory utility. |
use Win32::Unicode::Dir; use Win32::Unicode::Console; my $dir = "I \x{2665} Perl"; my $wdir = Win32::Unicode::Dir->new; $wdir->open($dir) || die $wdir->error; for ($wdir->fetch) { next if /^\.{1,2}$/; my $full_path = "$dir/$_"; if (file_type('f', $full_path)) { # $_ is file } elsif (file_type('d', $full_path)) # $_ is directory } } $wdir->close || dieW $wdir->error; my $cwd = getcwdW(); chdirW($change_dir_name); mkdirW $dir; rmdirW $dir;
Win32::Unicode::Dir is Unicode string directory utility.
my $wdir = Win32::Unicode::Dir->new;
$wdir->open($dir) or die $!
while (my $file = $wdir->fetch) { # snip }
or
for my $file ($wdir->fetch) { # snip }
fetch()
.
fetch()
.
$wdir->close or dieW $wdir->error
my $cwd = getcwdW;
chdirW $dir or die $!;
mkdirW $new_dir or die $!;
rmdirW($del_dir) or die $!;
rmtreeW $del_dir or die $!;
mkpathW $make_long_dir_name or die $!
cptreeW $from, $to or die $!;
If $from
delimiter of directory is a terminator, move the contents of $from
to $to
.
cptreeW 'foo/', 'hoge'; # before current directory tree # ---------------------------- # foo # foo/bar # foo/bar/baz # hoge # ---------------------------- # before current directory tree # ---------------------------- # foo # foo/bar # foo/bar/baz # hoge/ # hoge/bar # hoge/bar/baz # ----------------------------
If just a directory name, is as follows
cptreeW 'foo', 'hoge'; # before current directory tree # ---------------------------- # foo # foo/bar # foo/bar/baz # hoge # ---------------------------- # before current directory tree # ---------------------------- # foo # foo/bar # foo/bar/baz # hoge/foo # hoge/foo/bar # hoge/foo/bar/baz # ----------------------------
mvtreeW $from, $to or die $!;
If $from
delimiter of directory is a terminator, move the contents of $from
to $to
.
mvtreeW 'foo/', 'hoge'; # before current directory tree # ---------------------------- # foo # foo/bar # foo/bar/baz # hoge # ---------------------------- # after current directory tree # ---------------------------- # foo # hoge # hoge/bar # hoge/bar/baz # ----------------------------
If just a directory name, is as follows
mvtreeW 'foo', 'hoge'; # before current directory tree # ---------------------------- # foo # foo/bar # foo/bar/baz # hoge # ---------------------------- # after current directory tree # ---------------------------- # hoge # hoge/foo # hoge/foo/bar # hoge/foo/bar/baz # ----------------------------
findW \&wanted, $dir; sub wanted { my $file = $_; my $name = $Win32::Unicode::Dir::name; my $dir = $Win32::Unicode::Dir::dir; my $cwd = $Win32::Unicode::Dir::cwd; # $dir eq $cwd }
or
findW \&wanted, @dirs; sub wanted{ my $arg = shift; print $args->{file}; # eq $_ print $args->{name}; # eq $Win32::Unicode::Dir::name print $args->{cwd}; # eq $Win32::Unicode::Dir::cwd print $args->{dir}; # eq $Win32::Unicode::Dir::dir print $args->{path}; # full path }
or
findW \%options, @dirs;
wanted
preprocess
postprocess
no_chdir
finddepthW \&wanted, $driname;
equals to
findW { wanted => \&wanted, bydepth => 1 }, $dirname;
my $dir_size = dir_size($dir) or die $!
my @files = file_list $dir;
my @dirs = dir_list $dir;
Yuji Shimada <xaicron@cpan.org>
the Win32::Unicode::File manpage
the Win32::Unicode::Error manpage
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Win32::Unicode::Dir - Unicode string directory utility. |