Changeset 23561


Ignore:
Timestamp:
2011-01-13T11:49:38+13:00 (13 years ago)
Author:
kjdon
Message:

moved the block_filename from BasePlugin into util. then I don't need to duplicate it for DirectoryPlugin which doesn't inherit from BasePlugin

Location:
main/trunk/greenstone2/perllib
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/plugins/ArchivesInfPlugin.pm

    r23419 r23561  
    202202    my ($filename_full_path, $filename_no_path)
    203203        = &util::get_full_filenames($base_dir, $file);
    204     $self->block_filename($block_hash,$filename_full_path);
     204    &util::block_filename($block_hash,$filename_full_path);
    205205    return 1;
    206206    }
  • main/trunk/greenstone2/perllib/plugins/BasePlugin.pm

    r23544 r23561  
    382382}
    383383
    384 sub block_filename
    385 {
    386     my $self = shift(@_);
    387     my ($block_hash,$filename) = @_;
    388    
    389     if ($ENV{'GSDLOS'} =~ m/^windows$/) {
    390    
    391     # lower case the entire thing, eg for cover.jpg when its actually cover.JPG
    392     my $lower_filename = lc($filename);
    393     $block_hash->{'file_blocks'}->{$lower_filename} = 1;
    394 #   my $lower_drive = $filename;
    395 #   $lower_drive =~ s/^([A-Z]):/\l$1:/i;
    396    
    397 #   my $upper_drive = $filename;
    398 #   $upper_drive =~ s/^([A-Z]):/\u$1:/i;
    399 #   
    400 #   $block_hash->{'file_blocks'}->{$lower_drive} = 1;
    401 #   $block_hash->{'file_blocks'}->{$upper_drive} = 1;       
    402     }
    403     else {
    404     $block_hash->{'file_blocks'}->{$filename} = 1;
    405     }
    406 }
    407384
    408385# rename imported files and assoc files using URL encoding by default
     
    441418
    442419    if ($self->{'block_exp'} ne "" && $filename_full_path =~ /$self->{'block_exp'}/) {
    443     $self->block_filename($block_hash,$filename_full_path);
     420    &util::block_filename($block_hash,$filename_full_path);
    444421    }
    445422
     
    461438    }   
    462439    if (&util::fd_exists($coverfile)) {
    463         $self->block_filename($block_hash,$coverfile);
     440        &util::block_filename($block_hash,$coverfile);
    464441    }
    465442    }
  • main/trunk/greenstone2/perllib/plugins/DSpacePlugin.pm

    r23419 r23561  
    149149
    150150    if (&util::fd_exists($handle_filename)) {
    151     $self->block_filename($block_hash,$handle_filename);
     151    &util::block_filename($block_hash,$handle_filename);
    152152    }
    153153}
  • main/trunk/greenstone2/perllib/plugins/DirectoryPlugin.pm

    r23544 r23561  
    235235        foreach my $e (keys %$exts) {
    236236        # block the file
    237         $self->block_filename($block_hash,"$prefix$e");
     237        &util::block_filename($block_hash,"$prefix$e");
    238238        # set up as an associatd file
    239239        print STDERR "  $self->{'plugin_type'}: Associating $prefix$e with $tie_to version\n";
  • main/trunk/greenstone2/perllib/plugins/GreenstoneXMLPlugin.pm

    r23419 r23561  
    123123        }
    124124
    125         $self->block_filename($block_hash,$full_gsdl_assoc_filename);       
     125        &util::block_filename($block_hash,$full_gsdl_assoc_filename);       
    126126        }
    127127    }
  • main/trunk/greenstone2/perllib/plugins/HTMLPlugin.pm

    r23463 r23561  
    180180
    181181    my $html_fname = $filename_full_path;
    182     my @file_blocks;
    183182   
    184183    my ($language, $content_encoding) = $self->textcat_get_language_encoding ($filename_full_path);
     
    281280
    282281        # Allow for possibility of raw byte version and Unicode versions of file
    283         $self->block_filename($block_hash,$unicode_url_original_filename);
     282        &util::block_filename($block_hash,$unicode_url_original_filename);
    284283    }
    285284
    286285    # $url_original_filename = &util::upgrade_if_dos_filename($url_original_filename);
    287286   
    288     $self->block_filename($block_hash,$url_original_filename);
     287    &util::block_filename($block_hash,$url_original_filename);
    289288       
    290289    }
  • main/trunk/greenstone2/perllib/plugins/ISISPlugin.pm

    r23419 r23561  
    136136    print STDERR "$self->{'fdt_file_path'}\n";
    137137    my $fdt_file = $self->{'fdt_file_path'};
    138     $self->block_filename($block_hash,$fdt_file);
     138    &util::block_filename($block_hash,$fdt_file);
    139139    }
    140140    if (-e $self->{'xrf_file_path'}) {
    141141    print STDERR "$self->{'xrf_file_path'}\n";
    142142    my $xrf_file = $self->{'xrf_file_path'};
    143     $self->block_filename($block_hash,$xrf_file);
     143    &util::block_filename($block_hash,$xrf_file);
    144144    }
    145145   
  • main/trunk/greenstone2/perllib/plugins/MetadataCSVPlugin.pm

    r23419 r23561  
    113113
    114114    # add the file to the block list so that it won't be processed in read, as we will do all we can with it here
    115     $self->block_filename($block_hash,$filename);
     115    &util::block_filename($block_hash,$filename);
    116116
    117117    # Read the CSV file to get the metadata
  • main/trunk/greenstone2/perllib/plugins/MetadataXMLPlugin.pm

    r23419 r23561  
    254254    print $outhandle "MetadataXMLPlugin: processing $file\n" if ($self->{'verbosity'})> 1;
    255255    # add the file to the block list so that it won't be processed in read, as we will do all we can with it here
    256     $self->block_filename($block_hash,$filename);
     256    &util::block_filename($block_hash,$filename);
    257257
    258258    $self->{'metadataref'} = $extrametadata;
  • main/trunk/greenstone2/perllib/plugins/PagedImagePlugin.pm

    r23452 r23561  
    576576
    577577    if ($line =~ /imgfile=\"([^\"]+)\"/) {
    578         $self->block_filename($block_hash,$dir.$1);
     578        &util::block_filename($block_hash,$dir.$1);
    579579    }
    580580    if ($line =~ /txtfile=\"([^\"]+)\"/) {
    581         $self->block_filename($block_hash,$dir.$1);
     581        &util::block_filename($block_hash,$dir.$1);
    582582    }
    583583    }
     
    605605    # find the image file if there is one
    606606    if (defined $imgname && $imgname ne "") {
    607         $self->block_filename($block_hash, &util::filename_cat( $dir,$imgname));
     607        &util::block_filename($block_hash, &util::filename_cat( $dir,$imgname));
    608608    }
    609609    # find the text file if there is one
    610610    if (defined $txtname && $txtname ne "") {
    611         $self->block_filename($block_hash, &util::filename_cat($dir,$txtname));
     611        &util::block_filename($block_hash, &util::filename_cat($dir,$txtname));
    612612    }
    613613    }
  • main/trunk/greenstone2/perllib/util.pm

    r23484 r23561  
    11401140}
    11411141
     1142sub block_filename
     1143{
     1144    my ($block_hash,$filename) = @_;
     1145   
     1146    if ($ENV{'GSDLOS'} =~ m/^windows$/) {
     1147   
     1148    # lower case the entire thing, eg for cover.jpg when its actually cover.JPG
     1149    my $lower_filename = lc($filename);
     1150    $block_hash->{'file_blocks'}->{$lower_filename} = 1;
     1151#   my $lower_drive = $filename;
     1152#   $lower_drive =~ s/^([A-Z]):/\l$1:/i;
     1153   
     1154#   my $upper_drive = $filename;
     1155#   $upper_drive =~ s/^([A-Z]):/\u$1:/i;
     1156#   
     1157#   $block_hash->{'file_blocks'}->{$lower_drive} = 1;
     1158#   $block_hash->{'file_blocks'}->{$upper_drive} = 1;       
     1159    }
     1160    else {
     1161    $block_hash->{'file_blocks'}->{$filename} = 1;
     1162    }
     1163}
     1164
    11421165
    11431166sub filename_is_absolute
Note: See TracChangeset for help on using the changeset viewer.