read())) { if($file != '.' && $file != '..') { if(is_dir($path . $file)) { self::rmdir($path . $file); } elseif(is_file($path . $file)) { if(!@unlink($path . $file)) { throw new Exception('Error deleting file "' . $path . $file . '".'); } } } } $dir->close(); if(!@rmdir($path)) { throw new Exception('Error deleting directory "' . $path . '".'); } } }