Browse Source

Move the 'round up to next even second' logic to where it belongs -> out of the library and into the task

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@273907 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 22 years ago
parent
commit
a38deb31dc
2 changed files with 7 additions and 4 deletions
  1. +6
    -3
      src/main/org/apache/tools/ant/taskdefs/Zip.java
  2. +1
    -1
      src/main/org/apache/tools/zip/ZipOutputStream.java

+ 6
- 3
src/main/org/apache/tools/ant/taskdefs/Zip.java View File

@@ -824,9 +824,11 @@ public class Zip extends MatchingTask {
if (! skipWriting) {
ZipEntry ze = new ZipEntry (vPath);
if (dir != null && dir.exists()) {
ze.setTime(dir.lastModified());
// ZIPs store time with a granularity of 2 seconds, round up
ze.setTime(dir.lastModified() + 1999);
} else {
ze.setTime(System.currentTimeMillis());
// ZIPs store time with a granularity of 2 seconds, round up
ze.setTime(System.currentTimeMillis() + 1999);
}
ze.setSize (0);
ze.setMethod (ZipEntry.STORED);
@@ -957,7 +959,8 @@ public class Zip extends MatchingTask {

FileInputStream fIn = new FileInputStream(file);
try {
zipFile(fIn, zOut, vPath, file.lastModified(), null, mode);
// ZIPs store time with a granularity of 2 seconds, round up
zipFile(fIn, zOut, vPath, file.lastModified() + 1999, null, mode);
} finally {
fIn.close();
}


+ 1
- 1
src/main/org/apache/tools/zip/ZipOutputStream.java View File

@@ -653,7 +653,7 @@ public class ZipOutputStream extends DeflaterOutputStream {
| (time.getDate() << 16)
| (time.getHours() << 11)
| (time.getMinutes() << 5)
| ((time.getSeconds() + 2) >> 1);
| (time.getSeconds() >> 1);
byte[] result = new byte[4];
result[0] = (byte) ((value & 0xFF));


Loading…
Cancel
Save