diff --git a/src/apps/protocols/cifs/mode/files.pm b/src/apps/protocols/cifs/mode/files.pm index b7eb80104..e563e24b3 100644 --- a/src/apps/protocols/cifs/mode/files.pm +++ b/src/apps/protocols/cifs/mode/files.pm @@ -118,11 +118,12 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - 'directory:s@' => { name => 'directory' }, - 'file:s@' => { name => 'file' }, - 'max-depth:s' => { name => 'max_depth', default => 0 }, - 'timezone:s' => { name => 'timezone' }, - 'unit:s' => { name => 'unit', default => 's' } + 'filter-file:s' => { name => 'filter_file' } + 'directory:s@' => { name => 'directory' }, + 'file:s@' => { name => 'file' }, + 'max-depth:s' => { name => 'max_depth', default => 0 }, + 'timezone:s' => { name => 'timezone' }, + 'unit:s' => { name => 'unit', default => 's' } }); return $self; @@ -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> diff --git a/src/apps/protocols/cifs/mode/filescount.pm b/src/apps/protocols/cifs/mode/filescount.pm index 19ec631f5..2ed1b0e43 100644 --- a/src/apps/protocols/cifs/mode/filescount.pm +++ b/src/apps/protocols/cifs/mode/filescount.pm @@ -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> diff --git a/src/apps/protocols/cifs/mode/filesdate.pm b/src/apps/protocols/cifs/mode/filesdate.pm index 4c032fea5..e762407ea 100644 --- a/src/apps/protocols/cifs/mode/filesdate.pm +++ b/src/apps/protocols/cifs/mode/filesdate.pm @@ -89,10 +89,11 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - 'directory:s@' => { name => 'directory' }, - 'file:s@' => { name => 'file' }, - 'timezone:s' => { name => 'timezone' }, - 'unit:s' => { name => 'unit', default => 's' } + 'filter-file:s' => { name => 'filter_file' }, + 'directory:s@' => { name => 'directory' }, + 'file:s@' => { name => 'file' }, + 'timezone:s' => { name => 'timezone' }, + 'unit:s' => { name => 'unit', default => 's' } }); return $self; @@ -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. diff --git a/src/apps/protocols/cifs/mode/filessize.pm b/src/apps/protocols/cifs/mode/filessize.pm index 88ff8bcdd..a0f73e0ea 100644 --- a/src/apps/protocols/cifs/mode/filessize.pm +++ b/src/apps/protocols/cifs/mode/filessize.pm @@ -58,9 +58,10 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - 'directory:s@' => { name => 'directory' }, - 'file:s@' => { name => 'file' }, - 'max-depth:s' => { name => 'max_depth', default => 0 } + 'filter-file:s' => { name => 'filter_file' }, + 'directory:s@' => { name => 'directory' }, + 'file:s@' => { name => 'file' }, + 'max-depth:s' => { name => 'max_depth', default => 0 } }); return $self; @@ -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).