NAME
Win32::Unicode::Dir - Unicode string directory utility.
SYNOPSIS
use
Win32::Unicode::Dir;
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
;
DESCRIPTION
Win32::Unicode::Dir is Unicode string directory utility.
METHODS
- new
-
Create a Win32::Unicode::Dir instance.
my
$wdir
= Win32::Unicode::Dir->new;
- open($dir)
-
Like CORE::opendir.
$wdir
->
open
(
$dir
) or
die
$!
- fetch()
-
Like CORE::readdir.
while
(
my
$file
=
$wdir
->fetch) {
# snip
}
or
for
my
$file
(
$wdir
->fetch) {
# snip
}
- read()
-
Alias of
fetch()
. - readdir()
-
Alias of
fetch()
. - close()
-
Like CORE::closedir.
$wdir
->
close
or dieW
$wdir
->error
- error()
-
get error message.
FUNCTIONS
- getcwdW
-
Like Cwd::getcwd. get current directory.
my
$cwd
= getcwdW;
- chdirW($dir)
-
Like CORE::chdir.
chdirW
$dir
or
die
$!;
- mkdirW($new_dir)
-
Like CORE::mkdir.
mkdirW
$new_dir
or
die
$!;
- rmdirW($del_dir)
-
Like CORE::rmdir.
rmdirW(
$del_dir
) or
die
$!;
- rmtreeW($del_dir)
-
Like File::Path::rmtree.
rmtreeW
$del_dir
or
die
$!;
- mkpathW($make_long_dir_name)
-
Like File::Path::mkpath.
mkpathW
$make_long_dir_name
or
die
$!
- cptreeW($from, $to [, $over])
-
copy directory tree.
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 [, $over]))
-
move directory tree.
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($code, $dir)
-
like File::Find::find.
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
;
\%options
wanted
-
The value should be a code reference. Like File::Find#wanted
preprocess
-
The value should be a code reference. Like File::Find#preprocess
postprocess
-
The value should be a code reference. Like File::Find#postprocess
no_chdir
-
Boolean. If you set a true value will not change directories. In this case, $_ will be the same as $Win32::Unicode::Dir::name. Like File::Find#no_chdir
- finddepthW($code, $dir)
-
like File::Find::finddepth.
finddepthW \
&wanted
,
$driname
;
equals to
findW {
wanted
=> \
&wanted
,
bydepth
=> 1 },
$dirname
;
- dir_size($dir)
-
get directory size. this function are slow.
my
$dir_size
= dir_size(
$dir
) or
die
$!
- file_list($dir)
-
get files from $dir
my
@files
= file_list
$dir
;
- dir_list($dir)
-
get directories from $dir
my
@dirs
= dir_list
$dir
;
AUTHOR
Yuji Shimada <xaicron@cpan.org>
SEE ALSO
LICENSE
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.