-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue trying to read stats on file in zip files #62
Comments
I had a chance to look at this further. It seems that the zip_stat structure in libzip has changed considerably since version 0.9 on which libzip_all.c was based. Since the unix version defaults to use the libzip.so library, it will be different from that used for windows or if useLibzipSrc is defined when compiling for unix. More importantly it is possible that the actual structure may depend on the version of libzip.so installed and may not be known at compile time. Hence using this structure could cause problems. For that reason, I suspect this issue should probably be closed as Won't fix. That said, it proved useful and accurate for me, so in case anyone else really needs this, I will report my conclusions. Firstly, it makes more sense to use zip_stat_index and hence define walkFileStats as
I changed the ZipStat structure to be
I have tested this against the output from InfoZip V6 on over 1400 zip files that I have on my system. Tested using I was unable to get an 32-bit linux version to compile, so was untested. Observations name mtime
It would appear that such issues with handling dates occur with other zip libraries. compSize crc, size and compMethod all match. encryptionMethod is not output by Infozip, but based on the compSize calculation is probably accurate. Conclusion |
I am only starting to learn Nim and I want to read the stats of files inside a zip file. Zipfiles.nim does not expose this information, so I am attempting to modify it by creating a new iterator like this
But this does not return the correct results. I am building on 64-bit windows and the name and date look correct but the size and compressed size are not. But I need the final program to run on some 32-bit windows machines and when I compile for 32-bit, the name is still correct, but the date is just garbage and the sizes are also incorrect.
I got a little further by looking at the definition of ZipStat in libzip.nim which declares mtime to be of type time. If I change this to int32 then the fromUnix method returns the correct time for both 32-bit and 64-bit versions. The sizes are correct for the 32-bit
version, but not when compiled for 64-bit.
Since I don't need a 64-bit version of the program, this gives me what I need, but I would prefer to fix the issue properly.
Has anyone any ideas?
The text was updated successfully, but these errors were encountered: