protected function zipEpub($filename)
{
$zip = new \PclZip($filename);
// Open Publication Structure 2.0.1
// mimetype must be uncompressed, unencrypted, and the first file in the ZIP archive
$list = $zip->create($this->tmpDir . '/mimetype', PCLZIP_OPT_NO_COMPRESSION, PCLZIP_OPT_REMOVE_ALL_PATH);
if (0 == $list) {
return false;
}
$files = array();
foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->tmpDir)) as $file) {
if (!$file->isFile()) {
continue;
}
if ('mimetype' == $file->getFilename()) {
continue;
}
$files[] = $file->getPathname();
}
$list = $zip->add($files, '', $this->tmpDir);
if (0 == $list) {
return false;
}
return true;
}