I want to check if file do not exists. When file_exists() function returns false I can\'t be sure if the file do not exist or I don\'t have permiss
I wrote function which check if file can exists. It return false if there is no such file in filesystem, otherwise it returns true. My function checks (bottom-up) directory structure. One should be fairly sure that $root directory exists.
private function fileCanExists($root, $path) {
$root .= '/';
if (file_exists($root . $path))
return true;
while ($path != '.') {
$path = dirname($path);
if (file_exists($root . $path)) {
if (is_readable($root . $path))
return false;
else
return true;
}
}
return false;
}
That is what mean when I wrote:
I want to check if file do not exists.