我循环遍历系统上的所有文件,然后在hash_file()调用之前执行此检查,因为它总是给我带来诸如hash_file(): Read of 8192 bytes failed with errno=13 Permission denied或Failed to open stream: Resource temporarily unavailable:之类的错误
if (is_readable($path))
hash_file($path, ...);它还是能做到的。is_readable()显然不会检查它是否是可读的,否则即使使用此检查,它也不会不断地泄漏这些错误。
我如何确保所讨论的文件路径能够被读取,并且不会导致任何错误?
发布于 2022-02-04 00:32:28
首先,尝试用以下方法替换is_readable函数:
function f_is_readable($path) {
$f=@fopen($path,"r");
if ( $f===false ) {
return false;
}
fclose($f);
return true;
}如果它如您所期望的那样工作,我们可以假设is_readable函数对于您的PHP来说是错误的。
https://stackoverflow.com/questions/70979079
复制相似问题