Author Topic: Question about zipping unzipping  (Read 494 times)


  • Full Member
  • ***
  • Posts: 197
Question about zipping unzipping
« on: January 15, 2021, 08:19:20 pm »
In an app I've tried following:
- made a copy of a open office document
- changed extension of the copy to "zip"
- unpacked the zip-file
- modified the content.xml file contained in the unpacked zip-file
- packed back to zip-file
- changed extension back to "odt"
- tried to open with open office - file corrupt!!!

Tried manually the same and just unpacked followed by a direct pack
File corrupt again.

Something seems to happen when packing and unpacking
Is there someone that happens to know if one can do something
to fix this %)


  • Hero Member
  • *****
  • Posts: 8285
Re: Question about zipping unzipping
« Reply #1 on: January 15, 2021, 10:04:58 pm »
Two possibilities:
  • You unzipped to a flat file structure, i.e. all files end up in the same folder. LibreOffice however requires the original folder structure
  • You zipped the folder such that the folder is at the top level of the zip's internal file structure. This is wrong. You must chDir into the folder to be zipped, select all files and directories and zip them from there. This way the files are at the zip's top level file structure.

    The screenshot of the correct file structure (taken from PowerArchiver) shows the files and the META-INF folder at the top level. The screenshot of the wrong file structure shows the files and the META-INF folder, too, but they are contained in another folder named like the odt file.
« Last Edit: January 15, 2021, 10:43:09 pm by wp »
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...


  • Full Member
  • ***
  • Posts: 197
Re: Question about zipping unzipping
« Reply #2 on: January 15, 2021, 10:34:36 pm »
Thanks alot, that made it work!!! :D


TinyPortal © 2005-2018