Description
I'm interested in learning if there is any way to control sort order of files inside zip files using standard routines in PHP and/or Java.
I'm not primarily interested in using zip/unzip using shell_exec()
or similar, but it can be of interest if it provides with an easy to read solution.
With sort order it's safe to assume it means date/time if no sort order is available within the zip file. I've not read the specs so I wouldn't know.
Example
Files
foo.txt
bar.txt
test.txt
newfile.txt
Let's assume that each file contains the name of the file (foo.txt => foo.txt)
Problem
I want to attach a sort order to the files so that when unpacked using unzip
the files end up in the right order. This is important why? Because i use unzip -p
to pipe the content of the zip file.
The order in which the files are added to the archive should not matter.
Result
Intended result (for the sake of this example (using unzip -p))
test.txt
foo.txt
newfile.txt
bar.txt