This makes reproducible zip file creation a lot easier.
(the other common problem is non-deterministic recursion because it uses filesystem readdir order without sorting)
Readdir seems a bit hard to fix generally, since it is used in a bit too many places. For Unix we can probably take the FreeBSD scandir() implementation and wrap a new readd() around it. Too keep the states we will need to make a struct around DIR instead so we know where the namelist is.
The 0002 patch does not apply cleanly on my 3.0 - Is there a git repo of your version somewhere?
and then there are 2 problems:
1) there is another closedir(d) in the first loop.
2) the char *e; definition is still needed when you assign namelist[i]->d_name to it
Speaking of the chaos, I agree. But Schweda is still doing updates on FTP and it feels hard to word "try this new cool thing called git" correctly. (Although with PKZIP stuffing things like XZ to zip, you start to wonder whether this thing should be just implemented by an archive library like libarchive instead.)
The FreeBSD scandir I got here is https://github.com/lattera/freebsd/blob/master/lib/libc/gen/scandir.c . It is written in BSD-3-clause and depends on just malloc, qsort, readdir, and strcoll plus the dirent struct. Since we are only using the filename, it should not be hard to adapt to other systems either. It's just... a lot of slightly different copies of code to go through.
Last edit: Mingye Wang 2020-01-26
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
A revised patch with manpage updates is attached.
Readdir seems a bit hard to fix generally, since it is used in a bit too many places. For Unix we can probably take the FreeBSD
scandir()
implementation and wrap a new readd() around it. Too keep the states we will need to make a struct aroundDIR
instead so we know where thenamelist
is.Got the
scandir
patch here. You will need to fill in the fallback implementation part.The 0002 patch does not apply cleanly on my 3.0 - Is there a git repo of your version somewhere?
and then there are 2 problems:
1) there is another closedir(d) in the first loop.
2) the char *e; definition is still needed when you assign namelist[i]->d_name to it
There is a scandir impl in
https://github.com/microsoft/Windows-classic-samples/blob/master/Samples/Win7Samples/begin/sdkdiff/scandir.cpp but licence is probably not suitable. There are some other ports around on the net as part of the various libcs.
Oops! Yeah, my patches are based on zip 3.1d beta. You can find that version on the info-zip FTP (beta) or via https://antinode.info/ftp/info-zip . Me? I grabbed it from someone's FTP grab at https://github.com/zorba-the-geek/zip31d .
Speaking of the chaos, I agree. But Schweda is still doing updates on FTP and it feels hard to word "try this new cool thing called git" correctly. (Although with PKZIP stuffing things like XZ to zip, you start to wonder whether this thing should be just implemented by an archive library like libarchive instead.)
The FreeBSD scandir I got here is https://github.com/lattera/freebsd/blob/master/lib/libc/gen/scandir.c . It is written in BSD-3-clause and depends on just malloc, qsort, readdir, and strcoll plus the dirent struct. Since we are only using the filename, it should not be hard to adapt to other systems either. It's just... a lot of slightly different copies of code to go through.
Last edit: Mingye Wang 2020-01-26
There was a bug in the 1st scandir call param: "." vs n
https://github.com/distropatches/zip/commit/5063c9ce12c58f2512c2d00080d863d14b5d31f7
also worth mentioning that I once imported our openSUSE package patches into git to make the chaos more manageable:
https://github.com/distropatches/zip/commits/opensuse
otherwise it looks more like
https://github.com/bmwiedemann/openSUSE/tree/master/packages/z/zip