+
+ #Open Status File
+ print "V: Writing status $recordnum\n" if $Globals{ 'verbose' };
+ if( $OpenedRecord != $recordnum )
+ {
+ if( defined( $FileHandle ) )
+ {
+ print "D1: Closing status $recordnum\n" if $Globals{ 'debug' };
+ $OpenedRecord = 0;
+ close $FileHandle;
+ $FileHandle = undef;
+ }
+ print "D1: Opening status $recordnum\n" if $Globals{ 'debug' };
+ $FileHandle = &OpenFile( ["db", "archive"], $recordnum, ".status", "status", "old" );
+ if( !defined( $FileHandle ) ) { return undef; }
+ }
+ else { print "D1: Reusing status $recordnum\n" if $Globals{ 'debug' }; }
+
+ #Lock status file
+ print "D1: Locking status $recordnum\n" if $Globals{ 'debug' };
+ flock( $FileHandle, LOCK_EX ) || &fail( "Unable to lock record $recordnum\n" );
+
+ #Read in status file contents
+ print "D1: Saving status $recordnum\n" if $Globals{ 'debug' };