#47023 [Fbk->Csd]: ZipArchive fails under certain circumstances
| From: | pajoye@php.net | Date: | Mon, 12 Jan 2009 09:42:42 +0000 |
| Subject: | #47023 [Fbk->Csd]: ZipArchive fails under certain circumstances | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-132773@lists.php.net to get a copy of this message | ||
ID: 47023
Updated by: pajoye@php.net
Reported By: cristi at imagis dot ro
-Status: Feedback
+Status: Closed
Bug Type: Zip Related
Operating System: Windows XP SP3
PHP Version: 5.2.8
Previous Comments:
------------------------------------------------------------------------
[2009-01-07 09:36:17] pajoye@php.net
Seems to be the same problem than #46985, which is fixed now.
Please try a snapshot (http://windows.php.net/snapshots/)
------------------------------------------------------------------------
[2009-01-07 09:24:44] cristi at imagis dot ro
Description:
------------
I am experiencing some problems with ZipArchive, using PHP 5.2.8, with
php_zip supplied with this distribution. I am trying to archive couple
of folders and files using ZipArchive.
If i am replacing php_zip.dll with php_zip.dll from PHP 5.2.6 it works
without problems.
Testing same code using a PHP 5.2.7 installation (with php_zip.dll of
5.2.7) crashes archive also (see Expected Results section).
Reproduce code:
---------------
class My_ZipArchive extends ZipArchive
{
public function addDir($filename, $localname)
{
// Adds a directory recursivelly, keeping the same structure.
// @param string $filename The path to the file to add.
// @param string $localname Local name inside ZIP archive.
if($localname == NULL || empty($localname))
$localpath = "";
else
{
$localpath = $localname . '/';
$this->addEmptyDir($localname);
}
$iter = new DirectoryIterator($filename);
foreach($iter as $file)
{
// Only zip real files: no dots, no links.
if ($file->isDot() || (!$file->isFile() && !$file->isDir())) {
continue;
}
$method = $file->isFile() ? 'addFile' : 'addDir';
echo $file->getPathname().' - '.$method.'<br />';
$this->$method($file->getPathname(),
$localpath.$file->getFilename());
}
}
}
try
{
//create output archive
$zip = new My_ZipArchive();
$zip->open( 'archive.zip', ZIPARCHIVE::CREATE);
$zip->addDir( 'd:\_Work\test\output', '');
$result = $zip->close();
//finish create output archive
}
catch(Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
}
exit($result.'finished');
Expected result:
----------------
This code should make a zip with my files.
Actual result:
--------------
If i have 3 .php files to add them to zip i got a corrupted archive.
If i remove one of them i got a good zip archive.
If i am opening corrupted archive with a zip utility archive doesn't
seems to have any files within or is reported directly as corrupted. If
i am using a repair tool i got a working archive.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=47023&edit=1