Ignore:
Timestamp:
2010-12-01T11:42:27+13:00 (13 years ago)
Author:
davidb
Message:

Plugin code upgrade to support Greenstone working with filenames under Windows when then go beyond Latin-1 and start turning up in their DOS abbreviated form (e.g. Test~1.txt)

File:
1 edited

Legend:

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

    r23352 r23363  
    414414    my ($filename_full_path, $block_hash) = @_;
    415415
     416    $filename_full_path = &util::upgrade_if_dos_filename($filename_full_path);
     417
    416418    if ($self->{'block_exp'} ne "" && $filename_full_path =~ /$self->{'block_exp'}/) {
    417419    $block_hash->{'file_blocks'}->{$filename_full_path} = 1;
     
    426428    my ($filename, $block_hash) = @_;
    427429
     430    $filename = &util::upgrade_if_dos_filename($filename);
     431
    428432    if ($self->{'cover_image'}) {
    429433    my $coverfile = $filename;
    430434    $coverfile =~ s/\.[^\\\/\.]+$/\.jpg/;
    431     if (!-e $coverfile) {
     435    if (!&util::fd_exists($coverfile)) {
    432436        $coverfile =~ s/jpg$/JPG/;
    433437    }   
    434     if (-e $coverfile) {
     438    if (&util::fd_exists($coverfile)) {
    435439        $block_hash->{'file_blocks'}->{$coverfile} = 1;
    436440    }
     
    915919    # UTF-8 version of filename
    916920    if ((defined $ENV{"DEBUG_UNICODE"}) && ($ENV{"DEBUG_UNICODE"})) {
    917     print STDERR "****** Setting Source Metadata given: $octet_file\n";
     921    print STDERR "**** Setting Source Metadata given: $octet_file\n";
    918922    }
    919923   
     
    950954   
    951955    if ((defined $ENV{"DEBUG_UNICODE"}) && ($ENV{"DEBUG_UNICODE"})) {
    952     print STDERR "***** saving Source as:             $url_encoded_filename\n";
     956    print STDERR "****** saving Source as:             $url_encoded_filename\n";
    953957    }
    954958   
     
    966970
    967971    if ((defined $ENV{"DEBUG_UNICODE"}) && ($ENV{"DEBUG_UNICODE"})) {
    968     print STDERR "***** saving SourceFile as:         $renamed_raw_url\n";
     972    print STDERR "****** saving SourceFile as:         $renamed_raw_url\n";
    969973    }
    970974}
     
    10141018    # should we move this to read? What about secondary plugins?
    10151019    print STDERR "<Processing n='$file' p='$self->{'plugin_type'}'>\n" if ($gli);
    1016     print $outhandle "$self->{'plugin_type'} processing $file\n"
     1020    my $pp_file = &util::prettyprint_file($base_dir,$file);
     1021    print $outhandle "$self->{'plugin_type'} processing $pp_file\n"
    10171022        if $self->{'verbosity'} > 1;
    10181023
     
    12961301        my $zip_filename = $metadata->{$field};
    12971302        # overwrite the source_path
    1298         $doc_obj->{'source_path'} = $zip_filename;
     1303        $doc_obj->set_source_path($zip_filename);
    12991304        # and set the metadata
    13001305        $zip_filename = &util::filename_within_collection($zip_filename);
     
    13371342    my ($doc_obj, $filename) = @_;
    13381343
     1344    my $upgraded_filename = &util::upgrade_if_dos_filename($filename);
     1345
    13391346    $filename =~ s/\.[^\\\/\.]+$/\.jpg/;
    1340     if (exists $self->{'covers_missing_cache'}->{$filename}) {
    1341     # don't stat() for existence eg for multiple document input files
     1347    $upgraded_filename =~ s/\.[^\\\/\.]+$/\.jpg/;
     1348
     1349    if (exists $self->{'covers_missing_cache'}->{$upgraded_filename}) {
     1350    # don't stat() for existence e.g. for multiple document input files
    13421351    # (eg SplitPlug)
    13431352    return;
     
    13461355    my $top_section=$doc_obj->get_top_section();
    13471356
    1348     if (-e $filename) {
     1357    if (&util::fd_exists($upgraded_filename)) {
    13491358    $doc_obj->associate_source_file($filename);
    13501359        $doc_obj->associate_file($filename, "cover.jpg", "image/jpeg");
     
    13521361    } else {
    13531362    my $upper_filename = $filename;
     1363    my $upgraded_upper_filename = $upgraded_filename;
     1364
    13541365    $upper_filename =~ s/jpg$/JPG/;
    1355     if (-e $upper_filename) {
     1366    $upgraded_upper_filename =~ s/jpg$/JPG/;
     1367
     1368    if (&util::fd_exists($upgraded_upper_filename)) {
    13561369        $doc_obj->associate_source_file($upper_filename);
    13571370        $doc_obj->associate_file($upper_filename, "cover.jpg",
     
    13611374        # file doesn't exist, so record the fact that it's missing so
    13621375        # we don't stat() again (stat is slow)
    1363         $self->{'covers_missing_cache'}->{$filename} = 1;
     1376        $self->{'covers_missing_cache'}->{$upgraded_filename} = 1;
    13641377    }
    13651378    }
Note: See TracChangeset for help on using the changeset viewer.