Changeset 23388


Ignore:
Timestamp:
12/06/10 13:15:57 (11 years ago)
Author:
davidb
Message:

Further changes to deal with documents that use different filename encodings on the file-system. Now sets UTF8URL metadata to perform the cross-document look up. Files stored in doc.pm as associated files are now always raw filenames (rather than potentially UTF8 encoded). Storing of filenames seen by HTMLPlug when scanning for files to block on is now done in Unicode aware strings rather than utf8 but unware strings.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/util.pm

    r23371 r23388  
    530530    if ($ENV{'GSDLOS'} =~ m/^windows$/i) {
    531531    require Win32;
     532
     533    print STDERR "***** utf8 filename = $utf8_filename\n\n\n";
     534
    532535    my $unicode_filename = decode("utf8",$utf8_filename);
    533536    $real_filename = Win32::GetShortPathName($unicode_filename);
     
    10961099
    10971100    if ($ENV{'GSDLOS'} =~ m/^windows$/i) {
    1098     require Win32;
    10991101    # Ensure any DOS-like filename, such as test~1.txt, has been upgraded
    11001102    # to its long (Windows) version
     
    11051107        $filename_full_path = encode("utf8",$filename_full_path);
    11061108    }
     1109    }
     1110
     1111    return $filename_full_path;
     1112}
     1113
     1114
     1115sub downgrade_if_dos_filename
     1116{
     1117    my ($filename_full_path) = @_;
     1118
     1119    if ($ENV{'GSDLOS'} =~ m/^windows$/i) {
     1120    require Win32;
     1121
     1122    # Ensure the given long Windows filename is in a form that can
     1123    # be opened by Perl => convert it to a short DOS-like filename
     1124
     1125##  print STDERR "**** asked to downgrade: $filename_full_path\n";
     1126
     1127    $filename_full_path = Win32::GetShortPathName($filename_full_path);
     1128
     1129##  print STDERR "**** now: $filename_full_path\n";
     1130
     1131    # Make sure initial drive letter is lower-case (to fit in with rest of Greenstone)
     1132    $filename_full_path =~ s/^(.)/\l$1/;
    11071133    }
    11081134
     
    13841410    ($tailname,$dirname,$suffix) = File::Basename::fileparse($filename, "\\.(?:[^\\.]+?)\$");
    13851411    }
    1386     $suffix = "" if !$suffix;
     1412    if (!$suffix) {
     1413    $suffix = "";
     1414    }
     1415    else {
     1416    $suffix = lc($suffix);
     1417    }
    13871418
    13881419    if ($rename_method eq "url") {
Note: See TracChangeset for help on using the changeset viewer.