Question

I'm wondering if it's possible to remove a parent directory using PCLZip while the archive is loaded; without extracting it first and recompiling it.

I can remove the parent directory in the archive using:

$zip->delete(PCLZIP_OPT_BY_INDEX, '0');

And the zip listContent seems to show the parent directory removed

but when I browse the loaded archive the child files and folders are still hosted in the parent directory. I believe this is because their structure definitions still contain the parent directory.

Was it helpful?

Solution

This should not be possible - for all entries in ZIP archive the path is stored fully, including all parent directories. So to remove part of this path will require to process all entries, and re-write an archive file since data in all entry headers will be changed.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top