/** * Extracts the requested file in the package archive to the temp folder * and returns the path to the extracted file. * * @param string $filename * @param string $tempPrefix * @return string */ public function extractTar($filename, $tempPrefix = 'package_') { // search the requested tar archive in our package archive. // throw error message if not found. if (($fileIndex = $this->tar->getIndexByFilename($filename)) === false) { throw new PackageValidationException(PackageValidationException::FILE_NOT_FOUND, array('archive' => $this->archive, 'targetArchive' => $filename)); } // requested tar archive was found $fileInfo = $this->tar->getFileInfo($fileIndex); $filename = FileUtil::getTemporaryFilename($tempPrefix, preg_replace('!^.*?(\\.(?:tar\\.gz|tgz|tar))$!i', '\\1', $fileInfo['filename'])); $this->tar->extract($fileIndex, $filename); return $filename; }
/** * Extracts the requested file in the package archive to the temp folder * and returns the path to the extracted file. * * @param string $filename * @param string $tempPrefix * @return string */ public function extractTar($filename, $tempPrefix = 'package_') { // search the requested tar archive in our package archive. // throw error message if not found. if (($fileIndex = $this->tar->getIndexByFilename($filename)) === false) { throw new SystemException("tar archive '".$filename."' not found in '".$this->archive."'."); } // requested tar archive was found $fileInfo = $this->tar->getFileInfo($fileIndex); $filename = FileUtil::getTemporaryFilename($tempPrefix, preg_replace('!^.*?(\.(?:tar\.gz|tgz|tar))$!i', '\\1', $fileInfo['filename'])); $this->tar->extract($fileIndex, $filename); return $filename; }