isDir() ? 'rmdir' : 'unlink'; $action($fileinfo->getRealPath()); } rmdir($path); } else { unlink($path); } } }