{
if (recursive)
{
if (_deleteRecursive(file, true))
{
resourceFactory.fireEvent(new ResourceDeleted(this));
return true;
}
return false;
}
if ((file.listFiles() != null) && (file.listFiles().length != 0))
{
throw new RuntimeException("directory not empty");
}
if (OperatingSystemUtils.isWindows())
{
System.gc(); // ensure no lingering handles that would prevent deletion
}
if (file.delete())
{
resourceFactory.fireEvent(new ResourceDeleted(this));
return true;
}
return false;
}