Subversion Repositories DevTools

Rev

Rev 3832 | Rev 5709 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3832 Rev 4094
Line 202... Line 202...
202
        $self->recurse(1);
202
        $self->recurse(1);
203
 
203
 
204
    } elsif ( $opt =~ m/^--NoRecurse/ ) {
204
    } elsif ( $opt =~ m/^--NoRecurse/ ) {
205
        $self->recurse(0);
205
        $self->recurse(0);
206
 
206
 
207
    } elsif ( $opt =~ m/^--NoFullPath/ ) {
207
    } elsif ( $opt =~ m/^--NoFullPath/ ) {              # Default. Returned items relative to search base        
208
        $self->full_path(0);
208
        $self->full_path(0);
209
 
209
 
210
    } elsif ( $opt =~ m/^--FullPath/ ) {
210
    } elsif ( $opt =~ m/^--FullPath/ ) {                # Prepend base path to returned items
211
        $self->full_path(1);
211
        $self->full_path(1);
212
 
212
 
213
    } elsif ( $opt =~ m/^--FileListOnly/ ) {
213
    } elsif ( $opt =~ m/^--FileListOnly/ ) {            # Default. Return files only 
214
        $self->full_path(0);
214
        $self->full_path(0);
215
        $self->dirs_only(0);
215
        $self->dirs_only(0);
216
 
216
 
217
    } elsif ( $opt =~ m/^--DirListOnly/ ) {
217
    } elsif ( $opt =~ m/^--DirListOnly/ ) {             # Return dirs that contain selected files
218
        $self->dirs_only(1);
218
        $self->dirs_only(1);
219
 
219
 
-
 
220
    } elsif ( $opt =~ m/^--DirsToo/ ) {                 # Return files and directories
220
    } elsif ( $opt =~ m/^--DirsToo/ ) {
221
        $self->dirs_too(1);
-
 
222
 
-
 
223
    } elsif ( $opt =~ m/^--DirsOnly/ ) {                # Ignore non-directory elements    
-
 
224
        $self->dirs_only(2);
221
        $self->dirs_too(1);
225
        $self->dirs_too(1);
222
 
226
 
223
    } elsif ( $opt =~ m/^--FilterIn=(.+)/ ) {
227
    } elsif ( $opt =~ m/^--FilterIn=(.+)/ ) {
224
        $self->filter_in ( $1 );
228
        $self->filter_in ( $1 );
225
 
229
 
Line 255... Line 259...
255
 
259
 
256
my @search_list;             # Must be global to avoid closure problems
260
my @search_list;             # Must be global to avoid closure problems
257
my $search_len;
261
my $search_len;
258
my $search_base_dir;
262
my $search_base_dir;
259
my $search_dirs_too;
263
my $search_dirs_too;
-
 
264
my $search_no_files;
260
 
265
 
261
sub search
266
sub search
262
{
267
{
263
    my $self = shift;
268
    my $self = shift;
264
    $self->{base_dir} = $_[0] if (defined $_[0] );
269
    $self->{base_dir} = $_[0] if (defined $_[0] );
Line 293... Line 298...
293
    {
298
    {
294
        if ( $self->{recurse} )
299
        if ( $self->{recurse} )
295
        {
300
        {
296
            $search_dirs_too = $self->{dirs_too};
301
            $search_dirs_too = $self->{dirs_too};
297
            $search_base_dir = $self->{base_dir};
302
            $search_base_dir = $self->{base_dir};
-
 
303
            $search_no_files = ($self->{dirs_only} == 2);
298
            sub find_file_wanted
304
            sub find_file_wanted
299
            {
305
            {
-
 
306
                return if ( $search_no_files && ! -d $_ );              # skip if current is not a dir (assume file) and we only match dirs
300
                return if ( !$search_dirs_too && -d $_ );               # skip if current is dir and we are not including dirs
307
                return if ( !$search_dirs_too && -d $_ );               # skip if current is dir and we are not including dirs
301
                return if ( $search_base_dir eq $File::Find::name );    # skip if current is base_dir as we dont include it
308
                return if ( $search_base_dir eq $File::Find::name );    # skip if current is base_dir as we dont include it
302
                my $file = $File::Find::name;
309
                my $file = $File::Find::name;
303
                $file .= '/' if ( -d $_ );
310
                $file .= '/' if ( -d $_ && ! $search_no_files);
304
                push @search_list, substr($file, $search_len );
311
                push @search_list, substr($file, $search_len );
305
            }
312
            }
306
 
313
 
307
            #
314
            #
308
            #       Under Unix we need to follow symbolic links, but Perl's
315
            #       Under Unix we need to follow symbolic links, but Perl's
Line 399... Line 406...
399
        else
406
        else
400
        {
407
        {
401
            $path = $_;
408
            $path = $_;
402
        }
409
        }
403
 
410
 
404
        if ( $self->{dirs_only} )
411
        if ( $self->{dirs_only} == 1 )
405
        {
412
        {
406
            $path =~ s~/[^/]*$~~;
413
            $path =~ s~/[^/]*$~~;
407
        }
414
        }
408
 
415
 
409
        UniquePush( $self->{results}, $path);
416
        UniquePush( $self->{results}, $path);