COPYFILETIMES and SETATTR over ZIP archives

Hi there...

I was going to revive my old thread about ZIP, but i think a new one should be better.

Well, here i go, i changed my button to the following:

Copy ARCHIVE=keepfolder CREATEFOLDER="{s|nopath|noterm}.xpi" HERE WHENEXISTS=merge,replace FORCE COPYATTR=no [i]COPYDIRTIMES=no [b]COPYFILETIMES=no[/b] COPYOWNER=no COPYPROPERTIES=no COPYDESC=no COPYSECURITY=no [/i]

However, COPYFILETIMES=no seems to do nothing, ie. all three datestamps are being added:

(btw, im aware most of these args may does nothing on ZIPs, but i'm just trying to make them as small as possible)

Path = bootstrap.js
Folder = -
Size = 19797
Packed Size = 6293
Modified = 2013-03-14 08:20:02
Created = 2012-09-10 16:24:14
Accessed = 2012-09-10 16:24:14
Attributes = ....A

I did read on a post by Igor P. that he thinks it is "illegal" for ZIP archives to not have the modtime value, so i think that arg should at least get rid of accessed and created datestamps. But, it is illegal really? ie, what would happen if that contains just 0s? I tried it... for the last couple of days i have been trying to find a (erm..) human-readable ZIP spec, and found this from a ZIP creator in PHP:

$fr = "\x50\x4b\x03\x04";
$fr .= "\x14\x00";	// version needed to extract
$fr .= "\x00\x00";	// general purpose bit flag
$fr .= "\x08\x00";	// compression method
$fr .= "\x00\x00\x00\x00"; // last mod time and date
.......
// now add to central directory record
$cdrec = "\x50\x4b\x01\x02";
$cdrec .="\x00\x00";	// version made by
$cdrec .="\x14\x00";	// version needed to extract
$cdrec .="\x00\x00";	// general purpose bit flag
$cdrec .="\x08\x00";	// compression method
$cdrec .="\x00\x00\x00\x00"; // last mod time & date

So... i ran a hex editor and edited bytes 10-14 and the corresponding ones for the cd part, Zeroing them. Can you guess the result? it caused nothing.. I mean, after zeroing 8 bytes the only file within the archive still had the same modtime and was being properly readable. Huh?

Then, i started randomly zeroing other parts after the 'ushort' indicating the filename's length on the central-dir record and then noticed funny modtimes such as 1882 or 2056, heh.

Well, at this point i can see this might became off-topic from what it was/looked initially, but it is to understanding what i'm trying to achieve... a smaller ZIP archive with either removed or fake modtime. Why, you ask? well... the md5/sha1/xyz checksum will not change unnecessarily for example... :grin:

Additionally, i would love the ability to change the file permissions from ZIP files as well (without the need to change the original files and revert them once packed).

So... TL;DR;

  1. COPYFILETIMES=no should at least not set accessed/created.

  2. It'll be great if SETATTR could work recursively over selected ZIP archives.

What do you think?

Cheers.

Zip files have two sets of directory entries (the central directory, and a local directory). You can't have a directory entry without the time & date field, it's an integral part of the structure.

Ok, it was my impression that php spec usage was weak, but it confused me the fact it was using the same ZIP version than DO uses (0x504b0304) So, what i've edited lately is most likely the local dir part, which actually changed the real modtime shown by DO (being the others modtime unused here, but required, i understand)

Well, thx for the info, i know now a little more of what to search for, just for curiosity. i'll still love if these changes are implemented at some time, though :slight_smile: