Changeset 2241 for trunk/gsdl/perllib


Ignore:
Timestamp:
2001-04-01T21:19:25+12:00 (23 years ago)
Author:
sjboddie
Message:

Tidied up the ConvertToPlug stuff to get it working on Windows 95/98

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/perllib/plugins/ConvertToPlug.pm

    r2086 r2241  
    9494    if ($class eq "ConvertToPlug") {$class = shift (@_);}
    9595    my $self;
    96 # parsargv::parse might modify the list, so we do this by creating a copy
    97 # of the argument list.
     96    # parsargv::parse might modify the list, so we do this by creating a copy
     97    # of the argument list.
    9898    my @arglist = @_;
    99     my ($plugin_name,$generate_format, $kea_arg) = $class->parse_args(\@_);
     99    my ($plugin_name, $generate_format, $kea_arg) = $class->parse_args(\@_);
     100
     101    if ($class eq "PDFPlug" && $generate_format eq "text" &&
     102    $ENV{'GSDLOS'} =~ /^windows$/i) {
     103    print STDERR "Windows does not support pdf to text. PDFs will be converted to HTML instead\n";
     104    $generate_format = "html";
     105    }
    100106
    101107    if ($generate_format eq "text")
     
    135141sub tmp_area_convert_file {
    136142    my $self = shift (@_);
    137     my ($output_ext,$input_filename, $textref) = @_;
     143    my ($output_ext, $input_filename, $textref) = @_;
    138144
    139145    my $convert_to = $self->{'convert_to'};
     
    142148    my $colname = &util::use_collection();
    143149    my $tmp_dirname
    144     = &util::filename_cat($ENV{'GSDLHOME'},"collect",$colname,"tmp");
     150    = &util::filename_cat($ENV{'GSDLHOME'}, "collect", $colname, "tmp");
    145151    &util::mk_dir($tmp_dirname) if (!-e $tmp_dirname);
    146152
    147153    # derive tmp filename from input filename
    148     my ($tailname,$dirname,$suffix)
    149     = File::Basename::fileparse($input_filename,'\.[^\.]+$');
     154    my ($tailname, $dirname, $suffix)
     155    = &File::Basename::fileparse($input_filename, "\\.[^\\.]+\$");
    150156
    151157    # Remove any white space from filename -- no risk of name collision, and
     
    153159    $tailname =~ s/\s+//g;
    154160
    155     my $tmp_filename = &util::filename_cat($tmp_dirname,"$tailname$suffix");
    156 
    157     &util::soft_link($input_filename,$tmp_filename);
     161    my $tmp_filename = &util::filename_cat($tmp_dirname, "$tailname$suffix");
     162
     163    &util::soft_link($input_filename, $tmp_filename);
    158164
    159165    my $verbosity = $self->{'verbosity'};
    160     if ($verbosity>0)
    161     {
     166    if ($verbosity > 0) {
    162167    print STDERR "Converting $tailname$suffix to $convert_to format\n";
    163168    }
     
    166171    # making sure the converter gives us the appropriate output type
    167172    my $output_type = lc($convert_to);
    168     my $cmd = "gsConvert.pl -verbose $verbosity -output $output_type \"$tmp_filename\"";
     173    my $cmd = "perl -S gsConvert.pl -verbose $verbosity -output $output_type \"$tmp_filename\"";
    169174    $output_type = `$cmd`;
    170 
    171     # Check STDERR here
    172175
    173176    chomp $output_type;
     
    175178    print STDERR "Could not convert $tailname$suffix to $convert_to format\n";
    176179    return "";
    177 ### exit 1;
    178180    }
    179181
     
    184186    $self->{'convert_to_ext'} = $output_type;
    185187    my $output_filename = $tmp_filename;
     188
    186189    $output_filename =~ s/$suffix$/.$output_type/;
    187190
     
    197200    my $colname = &util::use_collection();
    198201    my $tmp_dirname
    199     = &util::filename_cat($ENV{'GSDLHOME'},"collect",$colname,"tmp");
     202    = &util::filename_cat($ENV{'GSDLHOME'}, "collect", $colname, "tmp");
    200203    &util::rm_r($tmp_dirname);
    201204    &util::mk_dir($tmp_dirname);
     
    229232
    230233    my $output_ext = $self->{'convert_to_ext'};
    231     my $conv_filename = $self->tmp_area_convert_file($output_ext,$filename);
     234    my $conv_filename = $self->tmp_area_convert_file($output_ext, $filename);
     235
    232236    if ("$conv_filename" eq "") {return 0;} # allows continue on errors
    233237    if (! -e "$conv_filename") {return 0;} # allows continue on errors
    234238    $self->{'conv_filename'} = $conv_filename;
    235239
    236 # Do encoding stuff
     240    # Do encoding stuff
    237241    my ($language, $encoding);
    238242    if ($self->{'input_encoding'} eq "auto") {
     
    253257    }
    254258
    255     BasPlug::read_file($self,$conv_filename, $encoding, \$text);
     259    &BasPlug::read_file($self, $conv_filename, $encoding, \$text);
    256260    if (!length ($text)) {
    257261        print $outhandle "$plugin_name: ERROR: $file contains no text\n" if $self->{'verbosity'};
     
    301305    {
    302306
    303     $ret_val = TEXTPlug::process($self,$textref,$pluginfo,
    304                      $tmp_dirname,$tmp_tailname,
    305                      $metadata,$doc_obj);
     307    $ret_val = &TEXTPlug::process($self, $textref, $pluginfo,
     308                      $tmp_dirname, $tmp_tailname,
     309                      $metadata, $doc_obj);
    306310    }
    307311    else
    308312    {
    309     $ret_val = HTMLPlug::process($self,$textref,$pluginfo,
    310                      $tmp_dirname,$tmp_tailname,
    311                      $metadata,$doc_obj);
     313    $ret_val = &HTMLPlug::process($self, $textref, $pluginfo,
     314                      $tmp_dirname, $tmp_tailname,
     315                      $metadata, $doc_obj);
    312316    }
    313317
    314318    # associate original file with doc object
    315319    my $cursection = $doc_obj->get_top_section();
    316     my $filename = &util::filename_cat($base_dir,$file);
     320    my $filename = &util::filename_cat($base_dir, $file);
    317321    $doc_obj->associate_file($filename, "doc.$doc_ext", undef, $cursection);
    318322
Note: See TracChangeset for help on using the changeset viewer.