This is an automated email from the ASF dual-hosted git repository.

hboutemy pushed a commit to branch MSOURCES-120
in repository https://gitbox.apache.org/repos/asf/maven-source-plugin.git


The following commit(s) were added to refs/heads/MSOURCES-120 by this push:
     new aadb596  display zip time, ie the long that gets into the zip stream
aadb596 is described below

commit aadb5965eafeeb6791ef886c507c48008dd3391c
Author: Hervé Boutemy <hbout...@apache.org>
AuthorDate: Wed Sep 4 18:30:30 2019 +0200

    display zip time, ie the long that gets into the zip stream
---
 src/it/reproducible/verify.groovy | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/src/it/reproducible/verify.groovy 
b/src/it/reproducible/verify.groovy
index 579a079..0801ae8 100644
--- a/src/it/reproducible/verify.groovy
+++ b/src/it/reproducible/verify.groovy
@@ -38,7 +38,7 @@ File jarFile = new File( deployDir, 
'reproducible-1.0-sources.jar' )
 ZipFile zipFile = new ZipFile( jarFile );
 
 r.append( 'encoding: ' + zipFile.getEncoding()  + '\n' )
-r.append( 'M size (cmp) crc      time          mode   name -comment; extra\n' )
+r.append( 'M size (cmp) crc      java time     zip time   mode   name 
-comment; extra\n' )
 
 String describeExtra( ZipExtraField[] extras )
 {
@@ -51,9 +51,21 @@ String describeExtra( ZipExtraField[] extras )
   return b.toString()
 }
 
+long javaToDosTime( Date d )
+{
+    int year = d.getYear() + 1900;
+    if ( year < 1980 )
+    {
+        return ZipEntry.DOSTIME_BEFORE_1980;
+    }
+    return ( year - 1980 ) << 25 | ( d.getMonth() + 1 ) << 21 |
+           d.getDate() << 16 | d.getHours() << 11 | d.getMinutes() << 5 |
+           d.getSeconds() >> 1;
+}
+
 for ( ZipArchiveEntry zae : zipFile.getEntries() )
 {
-    r.append( sprintf( "%d %4d (%3d) %8x %d %6o %s %s; %s\n", zae.getMethod(), 
zae.getSize(), zae.getCompressedSize(), zae.getCrc(), zae.getTime(), 
zae.getUnixMode(), zae.getName(), ( zae.getComment() == null ) ? '-' : 
zae.getComment(), describeExtra( zae.getExtraFields() ) ) )
+    r.append( sprintf( "%d %4d (%3d) %8x %d %d %6o %s %s; %s\n", 
zae.getMethod(), zae.getSize(), zae.getCompressedSize(), zae.getCrc(), 
zae.getTime(), javaToDosTime( zae.getLastModifiedDate() ), zae.getUnixMode(), 
zae.getName(), ( zae.getComment() == null ) ? '-' : zae.getComment(), 
describeExtra( zae.getExtraFields() ) ) )
 }
 zipFile.close();
 

Reply via email to