ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject cvs commit: ant/src/main/org/apache/tools/zip ZipOutputStream.java
Date Fri, 12 Nov 2004 10:21:36 GMT
bodewig     2004/11/12 02:21:36

  Modified:    src/main/org/apache/tools/zip ZipOutputStream.java
  Log:
  Don't create too many temporary objects, based on a patch by Kevin Jackson
  
  Revision  Changes    Path
  1.26      +18 -7     ant/src/main/org/apache/tools/zip/ZipOutputStream.java
  
  Index: ZipOutputStream.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/zip/ZipOutputStream.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- ZipOutputStream.java	5 Nov 2004 14:46:25 -0000	1.25
  +++ ZipOutputStream.java	12 Nov 2004 10:21:36 -0000	1.26
  @@ -581,7 +581,7 @@
           written += 2;
   
           // last mod. time and date
  -        writeOut(toDosTime(new Date(ze.getTime())).getBytes());
  +        writeOut(toDosTime(ze.getTime()));
           written += 4;
   
           // CRC
  @@ -669,7 +669,7 @@
           written += 2;
   
           // last mod. time and date
  -        writeOut(toDosTime(new Date(ze.getTime())).getBytes());
  +        writeOut(toDosTime(ze.getTime()));
           written += 4;
   
           // CRC
  @@ -770,13 +770,24 @@
        * @since 1.1
        */
       protected static ZipLong toDosTime(Date time) {
  +        return new ZipLong(toDosTime(time.getTime()));
  +    }
  +
  +    /**
  +     * Convert a Date object to a DOS date/time field.
  +     *
  +     * <p>Stolen from InfoZip's <code>fileio.c</code></p>
  +     *
  +     * @since 1.26
  +     */
  +    protected static byte[] toDosTime(long time) {
           Calendar cal = Calendar.getInstance();
  -        cal.setTime(time);
  +        cal.setTimeInMillis(time);
           int year = cal.get(Calendar.YEAR);
  -        int month = cal.get(Calendar.MONTH) + 1;
           if (year < 1980) {
  -            return DOS_TIME_MIN;
  +            return DOS_TIME_MIN.getBytes();
           }
  +        int month = cal.get(Calendar.MONTH) + 1;
           long value =  ((year - 1980) << 25)
               |         (month << 21)
               |	      (cal.get(Calendar.DAY_OF_MONTH) << 16)
  @@ -789,7 +800,7 @@
           result[1] = (byte) ((value & 0xFF00) >> 8);
           result[2] = (byte) ((value & 0xFF0000) >> 16);
           result[3] = (byte) ((value & 0xFF000000L) >> 24);
  -        return new ZipLong(result);
  +        return result;
       }
   
       /**
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message