Hi guys,
In the function below, how should I edit the code in order to make sure that the function returns true only after $dir have been totally emptied?
Would (filesize($dir) == 0) be a viable option?
I'm not sure an empty directory really returns 0 bytes.
Thanks a lot!
In the function below, how should I edit the code in order to make sure that the function returns true only after $dir have been totally emptied?
Would (filesize($dir) == 0) be a viable option?
I'm not sure an empty directory really returns 0 bytes.
Thanks a lot!
Code:
function hd_dir_clear($dir) {
$handle = opendir($dir);
while ($file = readdir($handle)) {
if ($file != "." AND $file != "..") {
$fullpath = $dir . "/" . $file;
if (!is_dir($fullpath)) {
unlink($fullpath);
} else {
hd_dir_clear($fullpath);
}
}
}
closedir($handle);
if(?????) {
return true;
} else {
return false;
}
}