Deletes files and/or directories in the specified path.
If the specified path is a directory the method will call itself recursively to process the contents. Once the contents have been removed the directory will also be removed.
string $path: A string containing either a file or directory path.
boolean TRUE for success or if path does not exist, FALSE in the event of an error.
protected function unlink($path) {
if (file_exists($path)) {
// Ensure the file / folder is writable.
chmod($path, 0700);
if (is_dir($path)) {
$dir = dir($path);
while (($entry = $dir
->read()) !== FALSE) {
if ($entry == '.' || $entry == '..') {
continue;
}
$this
->unlink($path . '/' . $entry);
}
$dir
->close();
return @rmdir($path);
}
return @unlink($path);
}
// If there's nothing to delete return TRUE anyway.
return TRUE;
}