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 $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

follow

has follow : ro byte;

Causes symbolic links to be followed.

See "follow" 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 stat, lstat, opendir fails or infinite loops are detected, 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:

  • follow

    follow : Int = 0

    Set "follow" 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.

Note:

If a symbolic link points to a directory that has already been processed, the files within that directory are skipped to prevent infinite loops.

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