package SafeIO;
$VERSION = '1.1';
use strict;
use FileHandle;
use Exporter;
our @ISA = qw(Exporter);
our @EXPORT=qw(ObtainLock ReleaseLock ReadFile WriteFile ErrorExit GetRemoteHost OpenFile CloseFile);
use FileCook;
# -- Bailout ---------------------------------------
my %files = ( );
sub CleanUp
{
foreach my $file (keys %files)
{
my $record = $files{$file};
$record or next;
if($record->{'lock'})
{
rmdir $file or print ("Could not release lock $file.
");
}
elsif($record->{'handle'})
{
$record->{'handle'}->close() or print ("Could not close $file.
");
}
}
}
sub ErrorExit
{
print "