private function lookup(string $path) : \Generator
{
$fileInfo = new class
{
use amp\Struct;
public $exists;
public $path;
public $size;
public $mtime;
public $inode;
public $buffer;
public $etag;
public $handle;
};
$fileInfo->exists = false;
$fileInfo->path = $path;
if (!($stat = (yield $this->filesystem->stat($path)))) {
return $fileInfo;
}
if ((yield $this->filesystem->isdir($path))) {
if ($indexPathArr = (yield from $this->coalesceIndexPath($path))) {
list($fileInfo->path, $stat) = $indexPathArr;
} else {
return $fileInfo;
}
}
$fileInfo->exists = true;
$fileInfo->size = (int) $stat["size"];
$fileInfo->mtime = $stat["mtime"] ?? 0;
$fileInfo->inode = $stat["ino"] ?? 0;
$inode = $this->useEtagInode ? $fileInfo->inode : "";
$fileInfo->etag = \md5("{$fileInfo->path}{$fileInfo->mtime}{$fileInfo->size}{$inode}");
if ($this->shouldBufferContent($fileInfo)) {
$fileInfo->buffer = (yield $this->filesystem->get($fileInfo->path));
$this->bufferedFileCount++;
}
return $fileInfo;
}