private function readArchive($filename) { $reader = new Reader($filename); //$reader = new \Mishak\ArchiveTar\Reader($filename); $reader->setReadContents(false); $reader->setBuffer(1000000); $count = 0; foreach ($reader as $record) { if (in_array($record['type'], array(Reader::REGULAR, Reader::AREGULAR), TRUE)) { //var_dump($record['filename']); ++$count; } } $reader->setReadContents(true); $this->count = $count; foreach ($reader as $record) { if (in_array($record['type'], array(Reader::REGULAR, Reader::AREGULAR), TRUE)) { } } }
public function performAction() { if (!file_exists($this->path)) { $this->response->error(new Expression('Path ? not found', $this->path)); return; } if (StringValue::create($this->path)->ends('.tar.gz')) { $filename = $this->path; $reader = new Reader($filename); $reader->setReadContents(false); $reader->setBuffer(1000000); $count = 0; foreach ($reader as $record) { if (in_array($record['type'], array(Reader::REGULAR, Reader::AREGULAR), TRUE)) { //var_dump($record['filename']); ++$count; } } $reader->setReadContents(true); $this->count = $count; foreach ($reader as $record) { if (in_array($record['type'], array(Reader::REGULAR, Reader::AREGULAR), TRUE)) { $this->addData($this->path . ':' . trim($record['filename']), $record['contents']); } } } else { $profiles = array(); if (is_dir($this->path)) { if ($handle = opendir($this->path)) { while (false !== ($entry = readdir($handle))) { if ($entry != "." && $entry != "..") { $profiles[] = $this->path . '/' . $entry; } } closedir($handle); } } else { $profiles[] = $this->path; } $this->count = count($profiles); foreach ($profiles as $filename) { $this->addData($filename, file_get_contents($filename)); } } if (!$this->noSquash) { $this->saveSymbolStats(); $this->saveRelatedStats(); } $this->response->success('All done!'); $this->response->addContent(new Info('Run ID ' . $this->runInstance->id . ' added')); }