Name

SPVM::File::Find - Finding Files in Subdirectories

Description

The File::Find class of SPVM has methods to find files in subdirectories.

Usage

use File::Find;

my $dir = "lib";

my $files_list = StringList->new;

File::Find->find([has files_list : StringList = $files_list] method : void ($dir : string, $file_base_name : string) {
  my $file = $dir;
  if ($file_base_name) {
    $file .= "/$file_base_name";
  }
  
  warn "$file";
}, $dir);

Gets file names:

use File::Find;
use StringList;

my $dir = "lib";

my $files_list = StringList->new;

File::Find->find([has files_list : StringList = $files_list] method : void ($dir : string, $file_base_name : string) {
  my $file = $dir;
  if ($file_base_name) {
    $file .= "/$file_base_name";
  }
  
  $self->{files_list}->push($file);
  
}, $dir);

my $files = $files_list->to_array;

Class Methods

static method find : void ($cb : File::Find::Handler, $top_dir : string, $options : object[] = undef);

Iterates each file recursively under the $top_dir and calls the $cb by the file.

See also

File::Find

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