private static function infoToJson(FileSystemInfo $info) { $isDir = $info instanceof DirectoryInfo; $virtualPath = Path::getVirtualPath($info->getFullName(), Config::getRootDir()); $json = array('name' => $info->getName(), 'path' => strlen($virtualPath) > 1 ? rtrim($virtualPath, '/') : $virtualPath, 'size' => $isDir ? 0 : $info->getSize(), 'last_access_time' => DateTimeUtils::toString($info->getLastAccessTime()), 'last_write_time' => DateTimeUtils::toString($info->getLastWriteTime()), 'is_dir' => $isDir); return $json; }
private function getNativeTimestamp(FileSystemInfo $info, $searchOptions = self::WITHOUT_CONTENT) { if ($info instanceof FileInfo) { $timestamp = $info->getLastWriteTime(); $this->cache->save($info->getFullName(), $timestamp); return $timestamp; } else { $directorySearchOptions = $searchOptions == self::WITHOUT_CONTENT ? DirectoryInfo::TOP_DIRECTORY_ONLY : DirectoryInfo::ALL_DIRECTORIES; $innerInfos = $info->getFileSystemInfos($directorySearchOptions); $timestamp = $info->getLastWriteTime(); foreach ($innerInfos as $innerInfo) { $innerTimestamp = $this->getTimestampHelper($innerInfo, $searchOptions); $timestamp = max($innerTimestamp, $timestamp); } $this->cache->save($info->getFullName(), $timestamp); return $timestamp; } }