<?php
function rmrf(string $path): int {
if (!file_exists($path)) return 0;
if (is_link($path) || !is_dir($path)) {
return unlink($path) ? 1 : 0;
}
$count = 0;
foreach (scandir($path) as $entry) {
if ($entry === '.' || $entry === '..') continue;
$count += rmrf($path . DIRECTORY_SEPARATOR . $entry);
}
rmdir($path);
return $count + 1;
}
$removed = rmrf('/tmp/build-cache');
echo "Removed $removed items\n";
Create a free account and build your private vault. Share publicly whenever you want.