Changeset 29795

Show
Ignore:
Timestamp:
19.03.2015 14:08:51 (5 years ago)
Author:
kjdon
Message:

change to using util method raw_filename_to_unicode. got this working on windows, now have to try again on linux and mac...

Files:
1 modified

Legend:

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

    r29763 r29795  
    4646use Unicode::Normalize; 
    4747 
     48use Win32; 
     49 
    4850BEGIN { 
    4951    @DirectoryPlugin::ISA = ('PrintInfo'); 
     
    410412    } 
    411413    @dir = sort readdir (DIR); 
    412     map { $_ = &unicode::raw_filename_to_url_encoded($_); print STDERR "****$_\n"; } @dir; 
     414    map {  $_ = &unicode::raw_filename_to_url_encoded($_); print STDERR "****$_\n"; } @dir; 
    413415    closedir (DIR); 
    414  
     416    #$_ = &util::get_dirsep_tail(&util::upgrade_if_dos_filename(&FileUtils::filenameConcatenate($dirname, $_), 1)); 
    415417    # Re-order the files in the list so any directories ending with .all are moved to the end 
    416418    for (my $i = scalar(@dir) - 1; $i >= 0; $i--) { 
     419        #print STDERR "*****file = $dir[$i]\n"; 
     420            #my $long = &Win32::GetLongPathName(&util::filename_cat($dirname,$dir[$i])); 
     421            #print STDERR "long = $long\n"; 
     422            #my $upgrade = &util::upgrade_if_dos_filename($dir[$i], 1); 
     423                #print STDERR "upgrade = $upgrade\n"; 
    417424    if (-d &FileUtils::filenameConcatenate($dirname, $dir[$i]) && $dir[$i] =~ /\.all$/) { 
    418425        push(@dir, splice(@dir, $i, 1)); 
     
    541548    last if ($maxdocs != -1 && ($count + $total_count) >= $maxdocs); 
    542549    next if ($subfile =~ /^\.\.?$/); 
    543  
     550     print STDERR "poo poo poo\n"; 
    544551    my $this_file_base_dir = $base_dir; 
    545552    my $raw_subfile = &unicode::url_encoded_to_raw_filename($subfile); 
    546     #my $unicode_subfile = &Encode::decode("utf8", $raw_subfile); 
    547     my $unicode_subfile = &Encode::decode(locale => $raw_subfile); 
    548  
    549     # Normalise the filename to canonical composition - on mac, filenames use decopmposed form for accented chars 
    550     $unicode_subfile = NFC($unicode_subfile); 
     553    my $unicode_subfile = &util::raw_filename_to_unicode($dirname, $raw_subfile); 
     554    print STDERR "raw = $raw_subfile, unicode = $unicode_subfile\n"; 
    551555 
    552556    my $raw_file_subfile = &FileUtils::filenameConcatenate($file, $raw_subfile); 
     
    558562        next; 
    559563    } 
    560     print STDERR "processing $raw_full_filename\n"; 
     564    print STDERR "** Dir Plugin processing $raw_full_filename\n"; 
    561565    # Follow Windows shortcuts 
    562566    if ($raw_subfile =~ m/(?i)\.lnk$/ && (($ENV{'GSDLOS'} =~ m/^windows$/i) && ($^O ne "cygwin"))) { 
     
    604608       print STDERR "****** subfile = $subfile, raw_subfile = $raw_subfile\n"; 
    605609    print STDERR &unicode::debug_unicode_string("subfile = $subfile, raw_subfile = $raw_subfile\n"); 
     610    print STDERR "looking up unicode version $unicode_subfile (". &unicode::debug_unicode_string($unicode_subfile).") \n"; 
    606611    # instead of using the subfile, we need unicode aware string 
    607612    ###my $lookup_name = decode("utf8", $raw_subfile); 
    608     ####print STDERR "lookup nmae = $lookup_name\n"; 
     613    ####print STDERR "lookup nmae = $lookup_name ( \n"; 
    609614    # Next add metadata read in XML files (if it is supplied) 
    610615    if ($additionalmetadata == 1) { 
     
    616621        if ($unicode_subfile =~ /^$filespec$/) { 
    617622        ###if ($lookup_name =~ /^$filespec$/) { 
    618             print $outhandle "File \"$unicode_subfile\" matches filespec \"$filespec\"\n"  
     623            print $outhandle "^^^^^^^^^File \"$unicode_subfile\" matches filespec \"$filespec\"\n"  
    619624            if ($verbosity > 2); 
    620625            my $mdref = &extrametautil::getmetadata(\%extrametadata, $filespec);