Ignore:
Timestamp:
2006-01-24T10:29:34+13:00 (18 years ago)
Author:
kjdon
Message:

made all plugins that implement read() call read_block to check process_exp, block_exp, smart blocking, cover image blocking etc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/perllib/plugins/ZIPPlug.pm

    r10254 r11090  
    8282    my $self = (defined $hashArgOptLists)? new BasPlug($pluginlist,$inputargs,$hashArgOptLists): new BasPlug($pluginlist,$inputargs);
    8383
    84     # BasPlug is explicitly set not to set process_exp if recursive plugin
    85     # Not sure of this reasoning.  Want it to be set in ZIPPlug, so explicitly
    86     # pass it in as default value
    87    
    88     ## do we need this???? --kjdon
    89     if (!$self->{'process_exp'}) {
    90     $self->{'process_exp'} = get_default_process_exp();
    91     }
    92 
    9384    return bless $self, $class;
    9485}
     
    113104    my $outhandle = $self->{'outhandle'};
    114105
    115     if ($file =~ /$self->{'process_exp'}/) {
    116 
    117     my $filename = $file;
    118     $filename = &util::filename_cat ($base_dir, $file) if $base_dir =~ /\w/;
    119     if (!-e $filename) {
    120         print $outhandle "ZIPPLug: WARNING: $filename does not exist\n";
    121         return undef;
    122     }
     106    # check process_exp, block_exp, associate_ext etc
     107    my ($block_status,$filename) = $self->read_block(@_);   
     108    return $block_status if ((!defined $block_status) || ($block_status==0));
    123109   
    124     my ($file_only) = $file =~ /([^\\\/]*)$/;
    125     my $tmpdir = &util::get_tmp_filename ();
    126     &util::mk_all_dir ($tmpdir);
    127 
    128     print $outhandle "ZIPPlug: extracting $file_only to $tmpdir\n"
    129         if $self->{'verbosity'} > 1;
    130 
    131     # save current working directory
    132     my $cwd = cwd();
    133     chdir ($tmpdir) || die "Unable to change to $tmpdir";
    134     &util::cp ($filename, $tmpdir);
    135    
    136     if ($file =~ /\.bz$/i) {
    137         $self->bunzip ($file_only);
    138     } elsif ($file =~ /\.bz2$/i) {
    139         $self->bunzip2 ($file_only);
    140     } elsif ($file =~ /\.(zip|jar)$/i) {
    141         $self->unzip ($file_only);
    142     } elsif ($file =~ /\.tar$/i) {
    143         $self->untar ($file_only);
    144     } else {
    145         $self->gunzip ($file_only);
    146     }
    147 
    148     chdir ($cwd) || die "Unable to change back to $cwd";
    149 
    150     my $numdocs = &plugin::read ($pluginfo, "", $tmpdir, $metadata, $processor, $maxdocs, $total_count, $gli);
    151     &util::rm_r ($tmpdir);
    152 
    153     $self->{'num_archives'} ++;
    154 
    155     return $numdocs;
    156 
     110    my ($file_only) = $file =~ /([^\\\/]*)$/;
     111    my $tmpdir = &util::get_tmp_filename ();
     112    &util::mk_all_dir ($tmpdir);
     113   
     114    print $outhandle "ZIPPlug: extracting $file_only to $tmpdir\n"
     115    if $self->{'verbosity'} > 1;
     116   
     117    # save current working directory
     118    my $cwd = cwd();
     119    chdir ($tmpdir) || die "Unable to change to $tmpdir";
     120    &util::cp ($filename, $tmpdir);
     121   
     122    if ($file =~ /\.bz$/i) {
     123    $self->bunzip ($file_only);
     124    } elsif ($file =~ /\.bz2$/i) {
     125    $self->bunzip2 ($file_only);
     126    } elsif ($file =~ /\.(zip|jar)$/i) {
     127    $self->unzip ($file_only);
     128    } elsif ($file =~ /\.tar$/i) {
     129    $self->untar ($file_only);
    157130    } else {
    158     return undef;
     131    $self->gunzip ($file_only);
    159132    }
     133   
     134    chdir ($cwd) || die "Unable to change back to $cwd";
     135   
     136    my $numdocs = &plugin::read ($pluginfo, "", $tmpdir, $metadata, $processor, $maxdocs, $total_count, $gli);
     137    &util::rm_r ($tmpdir);
     138   
     139    $self->{'num_archives'} ++;
     140   
     141    return $numdocs;
     142   
    160143}
    161144
Note: See TracChangeset for help on using the changeset viewer.