/** * Append the contents of an existing zip file to the current, WITHOUT re-compressing the data within it. * * @param string $file the path to the zip file to be added. * @param string $subPath place the contents in the $subPath sub-folder, default is '', and places the * content in the root of the new zip file. * @param AbstractZipArchive $writer Only used by the PHPZip files. Will write all output to the $writer, * instead of the stream. * @return bool true for success. */ public function appendZip($file, $subPath = '', $writer = null) { if ($this->isFinalized) { return false; } $this->writer = $writer; if (!empty($subPath)) { $subPath = ZipUtils::getRelativePath($subPath); $subPath = rtrim($subPath, '/'); if (!empty($subPath)) { $subPath .= '/'; $path = explode('/', $subPath); $nPath = ''; foreach ($path as $dir) { $nPath .= $dir . '/'; $fileEntry = ZipFileEntry::createDirEntry($nPath, time()); $data = $fileEntry->getLocalHeader(); $this->zipWrite($data); $this->FILES[$this->LFHindex++] = $fileEntry; $this->CDRindex++; } } } if (is_string($file) && is_file($file)) { $handle = fopen($file, 'r'); $this->processStream($handle, $subPath); fclose($handle); } else { if (is_resource($file) && get_resource_type($file) == "stream") { $curPos = ftell($file); $this->processStream($file, $subPath); fseek($file, $curPos, SEEK_SET); } } return true; }