01: // Copyright (c) 1997 Per M.A. Bothner.
02: // This is free software; for terms and warranty disclaimer see ./COPYING.
03:
04: package gnu.bytecode;
05:
06: import java.util.Hashtable;
07: import java.io.*;
08:
09: /** Information about one member of a ZipArchive. */
10:
11: public class ZipMember extends java.util.zip.ZipEntry {
12: ZipMember next;
13: long compressed_size;
14: // short filename_length;
15: long relative_offset_local_header; // start of local directory
16:
17: public ZipMember(String zname) {
18: super (zname);
19: }
20:
21: /* Where the actual data bytes start, withing the achive. */
22: long fileStart() {
23: return relative_offset_local_header + ZipArchive.LREC_SIZE + 4
24: + getName().length();
25: }
26:
27: public void print(PrintStream ps) {
28: ps.print(getName());
29: ps.println(" size: " + compressed_size + " position: "
30: + fileStart());
31: }
32:
33: boolean matches(String match_name) {
34: return match_name.equals(getName());
35: }
36:
37: public byte[] getData(ZipArchive archive) throws IOException {
38: archive.file.seek(fileStart());
39: byte[] result = new byte[(int) compressed_size];
40: archive.file.readFully(result);
41: return result;
42: }
43: };
|