Name
SPVM::File::Find - Find Files in Subdirectories
Description
File::Find class in SPVM has methods to find files in subdirectories.
Warnings:
Many tests are not written yet. This class has many bugs.
Usage
use File::Find;
my $top_dir = "lib";
File::Find->new->find(method : void ($info : File::Find::Info) {
my $dir = $info->dir;
my $file_name = $info->name;
}, $top_dir);
Gets file names:
use File::Find;
use StringList;
my $top_dir = "lib";
my $files_list = StringList->new;
File::Find->new->find([$files_list : StringList] method : void ($info : File::Find::Info) {
my $file_name = $info->name;
$files_list->push($file_name);
}, $top_dir);
my $files = $files_list->to_array;
Fields
bydepth
has bydepth : ro byte;
If this filed is a true value, "find" method reports the name of a directory only AFTER all its entries have been reported.
See "bydepth" in File::Find option for details.
preprocess
has preprocess : ro File::Find::Callback::Preprocess;
This callback is used to preprocess the current directory.
See "preprocess" in File::Find option for details.
postprocess
has postprocess : ro File::Find::Callback;
This callback is invoked just before leaving the currently processed directory.
See "postprocess" in File::Find option for details.
follow
has follow : ro byte;
Causes symbolic links to be followed.
See "follow" in File::Find option for details.
follow_fast
has follow_fast : ro byte;
This is similar to follow except that it may report some files more than once.
See "follow_fast" in File::Find option for details.
follow_skip
has follow_skip : ro byte;
See "follow_skip" in File::Find option for details.
dangling_symlinks
has dangling_symlinks : ro File::Find::Callback::DanglingSymlinks;
Specifies what to do with symbolic links whose target doesn't exist.
See "dangling_symlinks" in File::Find option for details.
no_chdir
has no_chdir : ro byte;
Does not chdir()
to each directory as it recurses.
See "no_chdir" in File::Find option for details.
dont_use_nlink
has dont_use_nlink : ro byte;
See "$dont_use_nlink" in File::Find option for details.
warn
has warn : ro byte;
If the value of this field is a true value and a system call such as chdir
fails, prints a warning message to stderr.
Class Methods
new
static method new : File::Find ($options : object[] = undef);
Creates a new File::Find object given the options $options, and returns the new object.
Options:
bydepth
bydepth : Int = 0
See "bydepth" field for details.
preprocess
preprocess : File::Find::Callback::Preprocess = undef
See "preprocess" field for details.
postprocess
postprocess : File::Find::Callback = undef
See "postprocess" field for details.
follow
follow : Int = 0
Set "follow" field to this value.
follow_fast
follow_fast : Int = 0
Set "follow_fast" field to this value.
follow_skip
follow_skip : Int = 0
If
follow
orfollow_fast
option is a true value and this option is not specified, the value is set to 1, otherwise set to 0.Set "follow_skip" field to this value.
dangling_symlinks
dangling_symlinks : File::Find::Callback::DanglingSymlinks = undef
Set "dangling_symlinks" field to this value.
no_chdir
no_chdir : Int = 0
Set "no_chdir" field to this value.
dont_use_nlink
dont_use_nlink : Int = 0
Set "dont_use_nlink" field to this value.
warn
warn : Int = 0
Set "warn" field to this value.
Instance Methods
find
method find : void ($cb : File::Find::Callback, $dir : string);
Iterates each file recursively under the $dir and calls the callback $cb by the file.
See Also
Porting
SPVM::File::Find
is a Perl's File::Find porting to SPVM.
Repository
Author
Yuki Kimoto kimoto.yuki@gmail.com
Copyright & License
Copyright (c) 2023 Yuki Kimoto
MIT License