/** * Get the PHP standard `stat()` function result * * The resulting table is returned with string indexes only * and few values transformed added depending on object's flags. * * @return array The result of the `stat()` function on the file, with string indexes only */ public function getStat() { if ($this->exists()) { $flags = $this->getFlags(); $stats = @stat($this->getRealPath()); if ($stats) { foreach ($stats as $i => $val) { if (!is_string($i)) { unset($stats[$i]); } else { if (self::STAT_DATETIME_FIELD & $this->flags && in_array($i, array('atime', 'mtime', 'ctime'))) { $stats[$i . 'DateTime'] = WebFilesystem::getDateTimeFromTimestamp($val); } elseif (self::STAT_SIZE_FIELD & $this->flags && $i === 'size') { $stats[$i . 'Transformed'] = WebFilesystem::getTransformedFilesize($val); } } } } return $stats; } return null; }
public function getDocBookStack() { if (!isset($this->cache['docbook_stack'])) { $truefile = $this; $filepath = $truefile->getRealPath(); if ($this->isLink() || $this->isRootLink()) { if ($this->isLink()) { try { $rp_tmp = realpath($this->getLinkTarget()); } catch (\Exception $e) { } if (empty($rp_tmp)) { $rp_tmp = $this->getRealPath(); } $truefile = new WebFileInfo($rp_tmp); } elseif ($this->isRootLink()) { try { $rp_tmp = @readlink($this->getPathname()); } catch (\Exception $e) { } if (empty($rp_tmp)) { $rp_tmp = $this->getRealPath(); } $truefile = new WebFileInfo($rp_tmp); } } $_size = $truefile->isDir() ? Helper::getDirectorySize($truefile->getPathname()) : $truefile->getSize(); $this->cache['docbook_stack'] = array('path' => $this->getDocBookPath(), 'type' => $this->getType(), 'route' => Helper::getRoute($this->getRealPath()), 'name' => $this->getHumanReadableFilename(), 'size' => WebFilesystem::getTransformedFilesize($_size), 'plainsize' => $_size, 'mtime' => WebFilesystem::getDateTimeFromTimestamp($truefile->getMTime()), 'description' => $this->getDescription(), 'trans' => $this->isDir() ? array() : $this->findTranslations(), 'dirpath' => dirname($this->getPathname()), 'lines_nb' => $this->isDir() ? null : Helper::getFileLinesCount($this->getRealPath()), 'extension' => $this->getExtension()); } return $this->cache['docbook_stack']; }