private void CleanupTemporaryFiles()
{
// Drain cleanup queue and clear it.
var tempDirBasePath = (TempDirBase != null ? TempDirBase.FullName : null);
TempDirBase = null;
// Only check and throw an IOException on un-removable files if the test
// was successful. Otherwise just report the path of temporary files
// and leave them there.
if (LuceneTestCase.SuiteFailureMarker /*.WasSuccessful()*/)
{
string f;
while (CleanupQueue.TryDequeue(out f))
{
try
{
if (System.IO.Directory.Exists(f))
System.IO.Directory.Delete(f, true);
else if (System.IO.File.Exists(f))
File.Delete(f);
}
catch (IOException e)
{
// Type suiteClass = RandomizedContext.Current.GetTargetType;
// if (suiteClass.IsAnnotationPresent(typeof(SuppressTempFileChecks)))
// {
Console.Error.WriteLine("WARNING: Leftover undeleted temporary files " + e.Message);
return;
// }
}
}
}
else
{
if (tempDirBasePath != null)
{
Console.Error.WriteLine("NOTE: leaving temporary files on disk at: " + tempDirBasePath);
}
}
}