/** * get file info by full path file name * * @param string $file * * @return FileInfo */ private function getFileInfo($file) { if (!file_exists($file)) { throw new NotFoundException(sprintf('file "%s" not found', $file)); } $fileStat = stat($file); $directory = dirname($file) == '.' ? '' : dirname($file); $fileInfo = new FileInfo(basename($file), $this->getDriverId(), $fileStat['mtime'], $directory); $fileInfo->setSize($fileStat['size']); $fileInfo->setWrite(is_writable($file)); $fileInfo->setMime($this->getMimeType($file)); $fileInfo->setLocked($this->driverOptions['locked']); $this->setDirs($fileInfo, $file); $tmb = $this->getThumb($file); if (!file_exists($tmb) && in_array($fileInfo->getMime(), ['image/jpeg', 'image/png', 'image/gif'])) { $fileInfo->setTmb(1); } elseif (file_exists($tmb)) { $fileInfo->setTmb(DIRECTORY_SEPARATOR . $tmb); } return $fileInfo; }