Changeset 2509


Ignore:
Timestamp:
2001-06-07T21:53:32+12:00 (23 years ago)
Author:
sjboddie
Message:

Fixed (bypassed really) a problem with the phind classifier on windows
where it was failing to clean up temporary files after it was finished.
The problem appears to be that a couple of temporary files that were
opened in the perl code were not being closed again (close() was failing),
hence they could not be deleted until the perl code had exited. The
cleanup is now done in an END block which seems to work ok. Should spend
more time trying to work out why the close() fails sometime in case it's
indicative of a more serious problem.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/perllib/classify/phind.pm

    r2507 r2509  
    3838use unicode;
    3939
     40my @removedirs = ();
     41
     42my %wanted_index_files = ('td'=>1,
     43              't'=>1,
     44              'ti'=>1,
     45              'tl'=>1,
     46              'tsd'=>1,
     47              'idb'=>1,
     48              'ib1'=>1,
     49              'ib2'=>1,
     50              'ib3'=>1,
     51              'i'=>1,
     52              'il'=>1,
     53              'w'=>1,
     54              'wa'=>1);
     55
    4056sub BEGIN {
    4157    @ISA = ('BasClas');
    4258}
    4359
     60sub END {
     61   
     62    # Tidy up stray files - we do this here as there's some weird problem
     63    # preventing us from doing it in the get_classify_info() function (on
     64    # windows at least) where the close() appears to fail on txthandle and
     65    # dochandle, thus preventing us from deleting those files
     66
     67    foreach my $dir (@removedirs) {
     68    if (-d $dir && opendir (DIR, $dir)) {
     69        my @files = readdir DIR;
     70        closedir DIR;
     71   
     72        foreach $file (@files) {
     73        next if $file =~ /^\.\.?$/;
     74        my ($suffix) = $file =~ /\.([^\.]+)$/;
     75        if (!defined $suffix || !defined $wanted_index_files{$suffix}) {
     76            # delete it!
     77            &util::rm (&util::filename_cat ($dir, $file));
     78        }
     79        }
     80    }
     81    }
     82}
    4483
    4584sub print_usage {
     
    83122"; }
    84123
    85 
    86 %wanted_index_files = ('td'=>1,
    87                't'=>1,
    88                'ti'=>1,
    89                'tl'=>1,
    90                'tsd'=>1,
    91                'idb'=>1,
    92                'ib1'=>1,
    93                'ib2'=>1,
    94                'ib3'=>1,
    95                'i'=>1,
    96                'il'=>1,
    97                'w'=>1,
    98                'wa'=>1);
    99 
    100 
    101 
    102124# Phrase delimiter symbols - these should be abstracted out someplace
    103125
     
    116138
    117139    my $out = $self->{'outhandle'};
    118 
    119 
    120     # Phind installation check
    121     # The phind phrase browser is research software and is not installed
    122     # by defualt.  If the user attepts to use it we warn them that it's a
    123     # bit dodgy, then tell them how to install it.  If they can do that
    124     # and get all the files in place, then we let them proceed.
    125    
    126     print $out "Checking Phind phrase browser requirements...\n";
    127140
    128141    # Ensure the Phind generate scripts are in place
     
    194207    $self->{'phindnumber'} = $phnumber;
    195208
     209    push(@removedirs, $phinddir) unless $self->{'untidy'};
     210
    196211    # open filehandles for documents and text
    197212    my $clausefile =  &util::filename_cat("$phinddir", "clauses");
     
    386401    &execute("mgpp_passes $osextra -f $mg_stem -T2 $mg_input", $verbosity, $out);
    387402
    388     # Tidy up stray files
    389     if (!$self->{'untidy'}) {
    390     print $out "\nCleaning up\n" if ($verbosity > 2);
    391     opendir (DIR, $phinddir) || die;
    392     my @files = readdir DIR;
    393     closedir DIR;
    394    
    395     foreach $file (@files) {
    396         next if $file =~ /^\.\.?$/;
    397         my ($suffix) = $file =~ /\.([^\.]+)$/;
    398         if (!defined $suffix || !defined $wanted_index_files{$suffix}) {
    399         # delete it!
    400         print $out "deleting $file\n"; # if $verbosity > 2;
    401         &util::rm (&util::filename_cat ($phinddir, $file));
    402         }
    403     }
    404     }
    405 
    406403    # Return the information about the classifier that we'll later want to
    407404    # use to create macros when the Phind classifier document is displayed.
Note: See TracChangeset for help on using the changeset viewer.