Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Archive::Zip Modify Date Oddity

by lhchin (Novice)
on Jan 03, 2017 at 09:29 UTC ( [id://1178835]=perlquestion: print w/replies, xml ) Need Help??

lhchin has asked for the wisdom of the Perl Monks concerning the following question:

use Archive::Zip; my $zip = Archive::Zip->new(); $zip->addFile($0,'test.txt'); $zip->writeToFileNamed('test.zip');

Save the above code as zip.pm and run the following command and grep original and post zip Modify date to compare.
Perl Library Zipped file extracted is always 1 second behind original modify file? Is this a bug with the library???

stat zip.pm | grep Modify && perl zip.pm && unzip test.zip && stat test.txt| grep Modify && rm test.*

Output

Modify: 2017-01-03 01:15:55.000000000 -0800
Archive: test.zip
inflating: test.txt
Modify: 2017-01-03 01:15:54.000000000 -0800

Replies are listed 'Best First'.
Re: Archive::Zip Modify Date Oddity
by Corion (Patriarch) on Jan 03, 2017 at 09:32 UTC

    The Zip (file format) uses FAT timestamps which only have a resolution of two seconds.

      Thank you for sharing the info. If this is to mimic windows time stamp, it is not desirable. Further test verified it does round down the original file Modify date to lower even-seconds.
      It is not the case when tested using Windows GUI or Unix Shell from Perl to zip file, it does not modify the original Modify date of the file.
      As such I have submitted an enhancement request to the Archive::Zip Library in cspan.org for ZIP64 support for higher-resolution NTFS or Unix file timestamps

        Zip64 support doesn't have anything to do with the granularity of the timestamp recorded in the zip file. It just allows file larger than 4Gig to be stored in a zip archive.

        The two second time granularity is dealt with in modern zip implementations by storing an extended timestamp field.

        Archive::Zip::SimpleZip supports this field.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1178835]
Approved by haukex
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (7)
As of 2024-04-23 18:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found