public static function delete($path)
{
if (is_file($path) || is_link($path)) {
$func = DIRECTORY_SEPARATOR === '\\' && is_dir($path) ? 'rmdir' : 'unlink';
if (!@$func($path)) {
// @ is escalated to exception
throw new Nette\IOException("Unable to delete '{$path}'.");
}
} elseif (is_dir($path)) {
foreach (new \FilesystemIterator($path) as $item) {
static::delete($item->getPathname());
}
if (!@rmdir($path)) {
// @ is escalated to exception
throw new Nette\IOException("Unable to delete directory '{$path}'.");
}
}
}