public function describe_size() { return ArtefactTypeFile::short_size($this->get('size')); }
public function read_archive() { if (!$this->handle) { $this->open_archive(); } if ($this->info) { return $this->info; } $this->info = (object) array('files' => 0, 'folders' => 0, 'totalsize' => 0, 'names' => array()); $this->foldernames = array(); if ($this->archivetype == 'zip') { while ($entry = zip_read($this->handle)) { $name = zip_entry_name($entry); $isfolder = substr($name, -1) == '/'; $size = $isfolder ? 0 : zip_entry_filesize($entry); $this->read_entry($name, $isfolder, $size); } } else { if ($this->archivetype == 'tar') { $list = $this->handle->listContent(); if (empty($list)) { throw new SystemException("Unknown archive type"); } foreach ($list as $entry) { $isfolder = substr($entry['filename'], -1) == '/'; $size = $isfolder ? 0 : $entry['size']; $this->read_entry($entry['filename'], $isfolder, $size); } } else { throw new SystemException("Unknown archive type"); } } $this->info->displaysize = ArtefactTypeFile::short_size($this->info->totalsize); return $this->info; }