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.

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.

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:

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

SPVM::File::Find - Github

Author

Yuki Kimoto kimoto.yuki@gmail.com

Copyright & License

Copyright (c) 2023 Yuki Kimoto

MIT License