}
return undef; # Need this to say "nothing found"
}
sub SetCacheParameter
{
my( $param, $scope, $value ) = @_;
if ( defined( $scope ) )
{
$CACHE{$scope}{$param} = $value;
}
else
{
$CACHE{$param} = $value;
}
SaveCache();
}
sub LoadCache
{
return if exists( $CACHE{'_cache_loaded_'} );
if ( -f $CACHEFILENAME )
{
my( $fileHandle ) = new IO::File;
if ( ! $fileHandle->open( "< ${CACHEFILENAME}" ) )
{
print STDERR "NPTest::LoadCache() : Problem opening ${CACHEFILENAME} : $!\n";
return;
}
my( $fileContents ) = join( "\n", <$fileHandle> );
$fileHandle->close();
my( $contentsRef ) = eval $fileContents;
%CACHE = %{$contentsRef};
}
$CACHE{'_cache_loaded_'} = 1;
}
sub SaveCache
{
delete $CACHE{'_cache_loaded_'};
my( $fileHandle ) = new IO::File;
if ( ! $fileHandle->open( "> ${CACHEFILENAME}" ) )
{
print STDERR "NPTest::LoadCache() : Problem saving ${CACHEFILENAME} : $!\n";
return;
}
my( $dataDumper ) = new Data::Dumper( [ \%CACHE ] );
$dataDumper->Terse(1);
print $fileHandle $dataDumper->Dump();
$fileHandle->close();
$CACHE{'_cache_loaded_'} = 1;
}
#
# (Questionable) Public Cache Management Functions
#
sub SetCacheFilename
{
my( $filename ) = @_;
# Unfortunately we can not validate the filename
# in any meaningful way, as it may not yet exist
$CACHEFILENAME = $filename;
}
#
# Test Harness Wrapper Functions
#
sub DetermineTestHarnessDirectory
{
my( $userSupplied ) = @_;
# User Supplied
if ( defined( $userSupplied ) && $userSupplied )
{
if ( -d $userSupplied )
{
return $userSupplied;
}
else
=5= |