Ignore:
Timestamp:
2001-04-20T11:44:50+12:00 (23 years ago)
Author:
sjboddie
Message:

* empty log message *

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/perllib/doc.pm

    r2326 r2327  
    4141# classification
    4242
     43my $OIDcount = 0;
     44
    4345sub new {
    4446    my $class = shift (@_);
     
    5052              'subsections'=>{},
    5153              'metadata'=>[],
    52               'text'=>""}, $class;
     54              'text'=>"",
     55              'OIDtype'=>"hash"}, $class;
    5356
    5457    $self->set_source_filename ($source_filename) if defined $source_filename;
     
    9396}
    9497
     98sub set_OIDtype {
     99    my $self = shift (@_);
     100    my ($type) = @_;
     101
     102    if ($type eq "incremental") {
     103    $self->{'OIDtype'} = $type;
     104    } else {
     105    $self->{'OIDtype'} = "hash";
     106    }
     107}
    95108
    96109sub set_source_filename {
     
    285298}
    286299
     300# calculate OID by hashing the contents of the document
    287301sub _calc_OID {
    288302    my $self = shift (@_);
     
    309323# methods dealing with OID, not groups of them.
    310324
    311 # if $OID is not provided one is calculated from hashing the
    312 # current contents of the document
    313 # An OID are actually stored as metadata of the document
     325# if $OID is not provided one is calculated
    314326sub set_OID {
    315327    my $self = shift (@_);
    316328    my ($OID) = @_;
    317329
    318     # if an OID wasn't provided then feed this document to
    319     # hashfile.exe
     330    # if an OID wasn't provided claculate one
    320331    if (!defined $OID) {
    321332    $OID = "NULL";
    322333
    323     my $filename = $self->get_source_filename();
    324     if (defined($filename) && -e $filename) {
    325 
    326         $OID = $self->_calc_OID ($filename);
    327 
     334    if ($self->{'OIDtype'} eq "incremental") {
     335        $OID = "D" . $OIDcount;
     336        $OIDcount ++;
     337       
    328338    } else {
    329 
    330         # this warning causes more confusion than it's worth I think
    331         # -- sorry Gordon.
    332 #       print STDERR "doc::set_OID source filename undefined/non-existant (continuing)\n";
     339        # "hash" OID - feed file to hashfile.exe
     340        my $filename = $self->get_source_filename();
     341        if (defined($filename) && -e $filename) {
     342
     343        $OID = $self->_calc_OID ($filename);
     344
     345        } else {
     346        $filename = &util::get_tmp_filename();
     347        if (!open (OUTFILE, ">$filename")) {
     348            print STDERR "doc::set_OID could not write to $filename\n";
     349        } else {
     350            $self->output_section('OUTFILE', $self->get_top_section(),
     351                      undef, 1);
     352            close (OUTFILE);
     353        }
    333354       
    334         $filename = &util::get_tmp_filename();
    335         if (!open (OUTFILE, ">$filename")) {
    336         print STDERR "doc::set_OID could not write to $filename\n";
    337         } else {
    338         $self->output_section('OUTFILE', $self->get_top_section(),
    339                       undef, 1);
    340         close (OUTFILE);
     355        $OID = $self->_calc_OID ($filename);
     356        &util::rm ($filename);
    341357        }
    342        
    343         $OID = $self->_calc_OID ($filename);
    344         &util::rm ($filename);
    345358    }
    346359    }
Note: See TracChangeset for help on using the changeset viewer.