|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2006-05-18 04:52 UTC] mpigozzi at e-portaltech dot it
Description:
------------
Using 1.3.1alpha, deleting a file on the root of a zip, then adding a new file with the same name on the same place (root directory), causes a corruption of the whole zip.
This happens only with zips with a directory structure.
Reproduce code:
---------------
$zip = new Zip()
if(!$zip->open("foo.zip"))
return false;
//delete
for($i=0; $i<$zip->numFiles;$i++) {
$statzip = $zip->statIndex($i);
if($statzip['name'] == "foofoo.xml")
$zip->delete($i);
}
//add
$zip->addFile("foo.zip","foofoo.xml");
//also doing the $zip->addFromString() causes corruption
//$zip->addFromString("foo.zip", $foofooxml_as_string);
Expected result:
----------------
...a zip with the new 'foofoo.xml' on the root of the directory structure
Actual result:
--------------
...a corrupted zip (I can see the directory structure with Ark, but then I cannot extract 'foofoo.xml').
As I have tried through Zend debugger, the delete is acting well, but the addFile() causes the corruption.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 00:00:01 2025 UTC |
Sorry, I've made a mistake in the code excerpt I wrote in the example. I mean instead: ... $zip->addFile("./temp/foofoo.xml","/foofoo.xml"); ... When I add a file to an existing archive (with a folder structure) from which I've removed a the same file (in the root), I get a corrupted zip. Just tried again now. Sorry for the inconvenience.