Changeset 2327 for trunk/gsdl/perllib/doc.pm
- Timestamp:
- 2001-04-20T11:44:50+12:00 (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/perllib/doc.pm
r2326 r2327 41 41 # classification 42 42 43 my $OIDcount = 0; 44 43 45 sub new { 44 46 my $class = shift (@_); … … 50 52 'subsections'=>{}, 51 53 'metadata'=>[], 52 'text'=>""}, $class; 54 'text'=>"", 55 'OIDtype'=>"hash"}, $class; 53 56 54 57 $self->set_source_filename ($source_filename) if defined $source_filename; … … 93 96 } 94 97 98 sub 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 } 95 108 96 109 sub set_source_filename { … … 285 298 } 286 299 300 # calculate OID by hashing the contents of the document 287 301 sub _calc_OID { 288 302 my $self = shift (@_); … … 309 323 # methods dealing with OID, not groups of them. 310 324 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 314 326 sub set_OID { 315 327 my $self = shift (@_); 316 328 my ($OID) = @_; 317 329 318 # if an OID wasn't provided then feed this document to 319 # hashfile.exe 330 # if an OID wasn't provided claculate one 320 331 if (!defined $OID) { 321 332 $OID = "NULL"; 322 333 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 328 338 } 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 } 333 354 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); 341 357 } 342 343 $OID = $self->_calc_OID ($filename);344 &util::rm ($filename);345 358 } 346 359 }
Note:
See TracChangeset
for help on using the changeset viewer.