Because of PHP\'s unlink()
not supporting exceptions natively, I\'m making a wrapper function for it. It should throw a FileNotFoundException
if, w
I would simplify the code:
public function deleteFile($path){
if (!file_exists($path) {
throw new FileNotFoundException();
}else{
unlink($path);
}
if (file_exists($path) {
throw new FileNotDeleted();
}
}
Then you don't have to catch the $errstr
and do complicated error catching. And it will work down to PHP 4 when exceptions were introduced.