PECL Zip 1.5.0, features additions, modify OpenDocument
Posted by Pierre in
PHP
Friday, July 14. 2006
This release tries to bring a bit of consistency in the new API. I try now to follow the actionName and actionIndex scheme where name and index are respetively the name and the position of an entry. The following methods have been renamed:
- rename zip::delete() to deleteIndex()
- add zip::deleteName()
- rename zip::statPath to zip::statName()
- rename zip::rename to zip::renameIndex()
And a couple of new methods made it in:
- renameName()
- unchangeName(), unchangeIndex(), unchangeAll(), undo the changes done to the current archive
- locateName(), returns the index of an entry (with or without dir, case sensitive or not)
- getNameIndex(), returns the name of the entry at the given index
Thanks to M. Pigozzi and Alexander Pak (PEAR’s Summer of Code project, OpenDocument support) to have catched a special type of archives (rarely used). This type is used by OpenOffice and/or other OpenDocument provider and was not fully supported by pecl/zip. It was not possible to modify such archive (like delete an element and add a new one with the same name entry). This release fixes this issue.
Another important fix has been applied to the zip::open method. It now returns the error code on failure and still true
on success. The correct way to call it should be, if you care to know why it was not possible to open a given path:
[php] <?php $zip = new Zip; $r = $zip->open($dirname . 'nofile') if ($r !== TRUE) { // an error occured and $r contains its error code } A locateName() example:
[php] <?php echo $zip->locateName('entry1.txt') . " "; echo $zip->locateName('eNtry2.txt') . " "; echo $zip->locateName('eNtry2.txt', ZIP::FL_NOCASE) . " "; echo $zip->locateName('enTRy2d.txt', ZIP::FL_NOCASE|ZIP::FL_NODIR) . " ";



