aboutsummaryrefslogtreecommitdiff
path: root/libjava/java/util
diff options
context:
space:
mode:
authorPer Bothner <bothner@gcc.gnu.org>1999-05-05 17:15:45 -0700
committerPer Bothner <bothner@gcc.gnu.org>1999-05-05 17:15:45 -0700
commitf7f65c793e4dc8760ba3860b4d3c1f69971a8302 (patch)
tree7bf82f617750267bd127d5d9683c53b930a2ef48 /libjava/java/util
parent0e9c6b0bf062a7627c286049abdb12b63bc2da65 (diff)
downloadgcc-f7f65c793e4dc8760ba3860b4d3c1f69971a8302.zip
gcc-f7f65c793e4dc8760ba3860b4d3c1f69971a8302.tar.gz
gcc-f7f65c793e4dc8760ba3860b4d3c1f69971a8302.tar.bz2
InflaterInputStream.java: New stub class.
8 * InflaterInputStream.java: New stub class. * ZipInputStream.java: New class. Partly works. * ZipConstants.java: Add two (internal) constants. * ZipEntry.java (timeFromDOS): New static (non-public) method. * ZipFile.java: Make it mostly work, except for compression. * ZipOutputStream.java: Start implementation. From-SVN: r26794
Diffstat (limited to 'libjava/java/util')
-rw-r--r--libjava/java/util/zip/ZipEntry.java32
1 files changed, 32 insertions, 0 deletions
diff --git a/libjava/java/util/zip/ZipEntry.java b/libjava/java/util/zip/ZipEntry.java
index d472de5..9eb34ba 100644
--- a/libjava/java/util/zip/ZipEntry.java
+++ b/libjava/java/util/zip/ZipEntry.java
@@ -33,6 +33,7 @@ public class ZipEntry
String name;
long size = -1;
long time = -1;
+ long relativeOffset = -1;
ZipEntry next;
@@ -80,5 +81,36 @@ public class ZipEntry
public void setTime (long time) { this.time = time; }
+ private final static short[] daysToMonthStart = {
+ //Jan Feb Mar Apr May Jun Jul
+ 0, 31, 31+28, 2*31+28, 2*31+28+30, 3*31+28+30, 3*31+28+2*30,
+ // Aug Sep Oct Nov Dec
+ 4*31+28+2*30, 5*31+28+2*30, 5*31+28+3*30, 6*31+28+3*30, 6*31+28+4*30};
+
+ /** Convert a DOS-style type value to milliseconds since 1970. */
+ static long timeFromDOS (int date, int time)
+ {
+ int sec = 2 * (time & 0x1f);
+ int min = (time >> 5) & 0x3f;
+ int hrs = (time >> 11) & 0x1f;
+ int day = date & 0x1f;
+ int mon = ((date >> 5) & 0xf) - 1;
+ int year = ((date >> 9) & 0x7f) + 10; /* Since 1970. */
+
+ // Guard against invalid or missing date causing IndexOutOfBoundsException.
+ if (mon < 0 || mon > 11)
+ return -1;
+
+ long mtime = (((hrs * 60) + min) * 60 + sec) * 1000;
+
+ // Leap year calculations are rather trivial in this case ...
+ int days = 365 * year + ((year+1)>>2);
+ days += daysToMonthStart[mon];
+ if ((year & 3) == 0 && mon > 1)
+ days++;
+ days += day;
+ return (days * 24*60*60L + ((hrs * 60) + min) * 60 + sec) * 1000L;
+ }
+
public String toString () { return name; }
}