Changeset 31459

Show
Ignore:
Timestamp:
06.03.2017 13:54:36 (3 years ago)
Author:
kjdon
Message:

now inherits from EncodingUtil?. When using local directory in metadata tables, needs to be in perl unicode form, not raw filesystem form.

Files:
1 modified

Legend:

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

    r30681 r31459  
    3131 
    3232use extrametautil; 
    33 use PrintInfo; 
     33use EncodingUtil; 
    3434use plugin; 
    3535use util; 
     
    4747 
    4848BEGIN { 
    49     @DirectoryPlugin::ISA = ('PrintInfo'); 
     49    @DirectoryPlugin::ISA = ('EncodingUtil'); 
    5050} 
    5151 
     
    8181    push(@{$hashArgOptLists->{"OptList"}},$options); 
    8282 
    83     my $self = new PrintInfo($pluginlist, $inputargs, $hashArgOptLists); 
     83    my $self = new EncodingUtil($pluginlist, $inputargs, $hashArgOptLists); 
    8484     
    8585    if ($self->{'info_only'}) { 
     
    395395    } 
    396396     
    397  
    398397    # Recur over directory contents. 
    399398    my (@dir, $subfile); 
     
    435434    # but with URL style slashes.  
    436435    my $local_dirname = &util::filename_within_directory_url_format($dirname, $base_dir); 
     436    ### need it in perl unicode, not raw filesystem 
     437    my $filename_encoding =  $self->guess_filesystem_encoding();   
     438         
     439    # copied this from set_Source_metadata in BasePlugin 
     440    if ((defined $filename_encoding) && ($filename_encoding ne "ascii")) { 
     441    # Use filename_encoding to map raw filename to a Perl unicode-aware string  
     442    $local_dirname = decode($filename_encoding,$local_dirname);      
     443    } 
     444    else { 
     445    # otherwise generate %xx encoded version of filename for char > 127 
     446    $local_dirname = &unicode::raw_filename_to_url_encoded($local_dirname); 
     447    } 
    437448 
    438449    # if we are in import folder, then local_dirname will be empty 
     
    451462        } 
    452463        delete($self->{'subdir_extrametakeys'}->{$local_dirname}); 
    453     } 
     464    }  
    454465    } 
    455466    # apply metadata pass for each of the files in the directory -- ignore 
     
    487498     
    488499    my ($subdir_re,$extrakey_dir) = &util::url_fileparse($ek); 
    489      
    490500    if ($extrakey_dir ne "") { 
    491501        # a subdir was specified 
     
    555565        next; 
    556566    } 
    557     print STDERR "** DirectoryPlugin processing $raw_full_filename\n"; 
     567 
    558568    # Follow Windows shortcuts 
    559569    if ($raw_subfile =~ m/(?i)\.lnk$/ && (($ENV{'GSDLOS'} =~ m/^windows$/i) && ($^O ne "cygwin"))) {