(plugin) apps::protocols::cifs - add --filter-file option (#4165)

This commit is contained in:
qgarnier 2023-01-23 10:20:01 +00:00 committed by GitHub
parent 70baae18f4
commit c00a652421
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 39 additions and 15 deletions

View File

@ -118,6 +118,7 @@ sub new {
bless $self, $class;
$options{options}->add_options(arguments => {
'filter-file:s' => { name => 'filter_file' }
'directory:s@' => { name => 'directory' },
'file:s@' => { name => 'file' },
'max-depth:s' => { name => 'max_depth', default => 0 },
@ -190,6 +191,9 @@ sub check_directory {
my $name = $dir . '/' . $file->[1];
next if (defined($self->{option_results}->{filter_file}) && $self->{option_results}->{filter_file} ne '' &&
$name !~ /$self->{option_results}->{filter_file}/);
if ($file->[0] == SMBC_DIR) {
if (defined($self->{option_results}->{max_depth}) && $level + 1 <= $self->{option_results}->{max_depth}) {
push @$list, { name => $name, level => $level + 1 };
@ -263,7 +267,7 @@ Check files.
=item B<--directory>
Check directory (Multiple option)
Check directory (Multiple option).
=item B<--max-depth>
@ -271,7 +275,11 @@ Don't check fewer levels (Default: '0'. Means current dir only). Used for direct
=item B<--file>
Check file (Multiple option)
Check file (Multiple option).
=item B<--filter-file>
Filter files (can be a regexp. Directory in the name).
=item B<--timezone>

View File

@ -144,7 +144,7 @@ Count files in a directory (can be recursive).
=item B<--directory>
Check files in the directory (Multiple option)
Check files in the directory (Multiple option).
=item B<--max-depth>

View File

@ -89,6 +89,7 @@ sub new {
bless $self, $class;
$options{options}->add_options(arguments => {
'filter-file:s' => { name => 'filter_file' },
'directory:s@' => { name => 'directory' },
'file:s@' => { name => 'file' },
'timezone:s' => { name => 'timezone' },
@ -155,6 +156,9 @@ sub manage_selection {
my $name = $dir . '/' . $file->[1];
next if (defined($self->{option_results}->{filter_file}) && $self->{option_results}->{filter_file} ne '' &&
$name !~ /$self->{option_results}->{filter_file}/);
$rv = $options{custom}->stat_file(file => $name);
if ($rv->{code} != 0) {
$self->{output}->add_option_msg(short_msg => "cannot stat file '" . $name . "': " . $rv->{message});
@ -206,6 +210,10 @@ Check files in the directory (no recursive) (Multiple option)
Check file (Multiple option)
=item B<--filter-file>
Filter files (can be a regexp. Directory in the name).
=item B<--timezone>
Set the timezone of display date.

View File

@ -58,6 +58,7 @@ sub new {
bless $self, $class;
$options{options}->add_options(arguments => {
'filter-file:s' => { name => 'filter_file' },
'directory:s@' => { name => 'directory' },
'file:s@' => { name => 'file' },
'max-depth:s' => { name => 'max_depth', default => 0 }
@ -120,6 +121,9 @@ sub check_directory {
my $name = $dir . '/' . $file->[1];
next if (defined($self->{option_results}->{filter_file}) && $self->{option_results}->{filter_file} ne '' &&
$name !~ /$self->{option_results}->{filter_file}/);
if ($file->[0] == SMBC_DIR) {
if (defined($self->{option_results}->{max_depth}) && $level + 1 <= $self->{option_results}->{max_depth}) {
push @$list, { name => $name, level => $level + 1 };
@ -175,6 +179,10 @@ Can get sub directory size with --max-depth option.
Check file (Multiple option)
=item B<--filter-file>
Filter files (can be a regexp. Directory in the name).
=item B<--max-depth>
Don't check fewer levels (Default: '0'. Means current dir only).