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

Additional routines (and few upgraded) to help 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/doc.pm

    r23278 r23362  
    6464    # the docsave processor now calls set_lastmodified
    6565
    66     $self->{'source_path'} = $source_filename;
     66    $self->set_source_path($source_filename);
    6767   
    6868    if (defined $source_filename) {
     
    7676    return $self;
    7777}
     78
     79
     80sub set_source_path
     81{
     82    my $self = shift @_;
     83    my ($source_filename) = @_;
     84
     85    if (defined $source_filename) {
     86    # On Windows the source_filename can be in terse DOS format
     87    # e.g. test~1.txt
     88
     89    $self->{'terse_source_path'} = $source_filename;
     90
     91    if (-e $source_filename) {
     92        # See if we can do better for Windows with a filename
     93        if ($ENV{'GSDLOS'} =~ /^windows$/i) {
     94        require Win32;
     95        $self->{'source_path'} = Win32::GetLongPathName($source_filename);
     96        }
     97        else {
     98        # For Unix-based systems, there is no difference between the two
     99        $self->{'source_path'} = $source_filename;
     100        }
     101    }
     102    else {
     103        print STDERR "Warning: In doc::set_source_path(), file\n";
     104        print STDERR "           $source_filename\n";
     105        print STDERR "         does not exist\n";
     106       
     107        # (default) Set it to whatever we were given
     108        $self->{'source_path'} = $source_filename;
     109    }   
     110    }
     111    else {
     112    # Previous code for setting source_path allowed for
     113    # it to be undefined, so continue this practice
     114    $self->{'terse_source_path'} = undef;
     115    $self->{'source_path'} = undef;
     116    }
     117}
     118
     119
     120sub get_source_path
     121{
     122    my $self = shift @_;
     123
     124    return $self->{'terse_source_path'};
     125}
     126
    78127# set lastmodified for OAI purposes, added by GRB, moved by kjdon
    79128sub set_lastmodified {
    80129    my $self = shift (@_);
    81130
    82     my $source_path = $self->{'source_path'};
     131    my $source_path = $self->{'terse_source_path'};
    83132   
    84133    if (defined $source_path && (-e $source_path)) {
     
    207256    my $self = shift (@_);
    208257
    209     return $self->{'source_path'};
     258    return $self->{'terse_source_path'};
    210259}
    211260
Note: See TracChangeset for help on using the changeset viewer.