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/plugouts/BasePlugout.pm

    r22818 r23363  
    640640    $dir = "" unless defined $dir;
    641641       
    642    
    643     my $real_filename = $assoc_file_rec->[0];
     642    my $utf8_real_filename = $assoc_file_rec->[0];
     643
    644644    # for some reasons the image associate file has / before the full path
    645     $real_filename =~ s/^\\(.*)/$1/i;
     645    $utf8_real_filename =~ s/^\\(.*)/$1/i;
     646
     647    my $real_filename = &util::utf8_to_real_filename($utf8_real_filename);
     648
    646649    if (-e $real_filename) {
    647650
     
    653656                     "gsdlassocfile",
    654657                     "$afile:$assoc_file_rec->[2]:$dir");
    655     } elsif ($self->{'verbosity'} > 2) {
     658    } elsif ($self->{'verbosity'} > 1) {
    656659        print $outhandle "BasePlugout::process couldn't copy the associated file " .
    657660        "$real_filename to $afile\n";
     
    688691    # for some reasons the image associate file has / before the full path
    689692    $real_filename =~ s/^\\(.*)/$1/i;
    690     if (-e $real_filename) {
     693
     694    my $raw_filename;
     695    if ($ENV{'GSDLOS'} =~ m/^windows$/i) {
     696        # Need to generate DOS version of filename to test in '-e $raw_filename' below
     697        require Win32;
     698        my $unicode_filename = Encode::decode("utf8",$real_filename);
     699###     print STDERR "***### files to field: ", &unicode::debug_unicode_string($unicode_filename),"\n";
     700
     701        $raw_filename = Win32::GetShortPathName($unicode_filename);
     702    }
     703    else {
     704        $raw_filename = $real_filename;
     705    }
     706
     707    if (-e $raw_filename) {
    691708
    692709#       if (defined $collect_dir) {
     
    701718        $reverse_lookups->{$real_filename} = 1;
    702719        }
    703         push(@{$oid_files->{$field}},$full_file);
     720###     push(@{$oid_files->{$field}},$full_file);
     721        push(@{$oid_files->{$field}},$raw_filename);
    704722    }
    705723    else {
Note: See TracChangeset for help on using the changeset viewer.