author | ab |
Thu, 24 Apr 2008 17:38:08 +0200 | |
changeset 1979 | 6eff3f1f1b80 |
parent 1839 | c10cd58ec334 |
child 1980 | 1c868f4b1a7d |
permissions | -rw-r--r-- |
624 | 1 |
" |
2 |
COPYRIGHT (c) 1998 by eXept Software AG |
|
1839 | 3 |
All Rights Reserved |
624 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
900 | 12 |
"{ Package: 'stx:libbasic2' }" |
13 |
||
622 | 14 |
Object subclass:#ZipArchive |
970 | 15 |
instanceVariableNames:'file mode archiveName firstEntry lastEntry |
1979 | 16 |
recentlyExtractedEntries centralDirectory' |
970 | 17 |
classVariableNames:'RecentlyUsedZipArchives FlushBlock ECREC_SIZE LREC_SIZE CREC_SIZE |
18 |
SIZE_CENTRAL_DIRECTORY TOTAL_ENTRIES_CENTRAL_DIR |
|
19 |
C_COMPRESSED_SIZE C_RELATIVE_OFFSET_LOCAL_HEADER |
|
20 |
C_FILENAME_LENGTH C_UNCOMPRESSED_SIZE C_CENTRALHEADERSIGNATURE |
|
21 |
C_LOCALHEADERSIGNATURE C_CENTRALENDSIGNATURE |
|
22 |
ZipFileFormatErrorSignal COMPR_STORED COMPR_SHRUNK COMPR_REDUCED1 |
|
23 |
COMPR_REDUCED2 COMPR_REDUCED3 COMPR_REDUCED4 COMPR_IMPLODED |
|
24 |
COMPR_TOKENIZED COMPR_DEFLATED' |
|
25 |
poolDictionaries:'' |
|
26 |
category:'System-Support-FileFormats' |
|
622 | 27 |
! |
28 |
||
1979 | 29 |
Object subclass:#ZipCentralDirectory |
30 |
instanceVariableNames:'numberOfThisDisk centralDirectoryStartDiskNumber |
|
31 |
centralDirectoryTotalNoOfEntriesOnThisDisk |
|
32 |
centralDirectoryTotalNoOfEntries centralDirectorySize |
|
33 |
centralDirectoryStartOffset zipCommentLength zipComment |
|
34 |
digitalSignatureDataSize digitalSignatureData' |
|
35 |
classVariableNames:'' |
|
36 |
poolDictionaries:'' |
|
37 |
privateIn:ZipArchive |
|
38 |
! |
|
39 |
||
622 | 40 |
Object subclass:#ZipMember |
1979 | 41 |
instanceVariableNames:'next versionMadeBy versionNeedToExtract generalPurposBitFlag |
42 |
compressionMethod lastModFileTime lastModFileDate crc32 |
|
43 |
compressedSize uncompressedSize fileNameLength extraFieldLength |
|
44 |
fileCommentLength diskNumberStart internalFileAttributes |
|
45 |
externalFileAttributes relativeLocalHeaderOffset fileName |
|
46 |
extraField fileComment dataStart data' |
|
970 | 47 |
classVariableNames:'' |
48 |
poolDictionaries:'' |
|
49 |
privateIn:ZipArchive |
|
622 | 50 |
! |
51 |
||
636 | 52 |
!ZipArchive primitiveDefinitions! |
53 |
%{ |
|
54 |
||
720 | 55 |
|
636 | 56 |
#include <stdio.h> |
57 |
||
58 |
#define uchar unsigned char |
|
59 |
#define ushort unsigned short |
|
60 |
#define ulong unsigned long |
|
61 |
||
62 |
/* |
|
63 |
* inflate definitions |
|
64 |
*/ |
|
65 |
#define PKZIP_BUG_WORKAROUND /* PKZIP 1.93a problem--live with it */ |
|
66 |
#ifndef WSIZE /* default is 32K */ |
|
67 |
# define WSIZE 0x8000 /* window size--must be a power of two, and at least */ |
|
68 |
#endif /* 32K for zip's deflate method */ |
|
69 |
||
70 |
#define NEXTBYTE (*inPtr++) |
|
637 | 71 |
#define XXXFLUSH(n) slide += (n) |
723 | 72 |
#define FLUSH(n) { bcopy(slide, outPtr, (n)); outPtr += (n); } |
73 |
||
74 |
#ifdef DEBUG |
|
1839 | 75 |
# define Trace(x) if (debugTrace) { console_fprintf x ; } |
636 | 76 |
#else |
77 |
# define Trace(x) /* nothing */ |
|
78 |
#endif |
|
79 |
||
80 |
/* Huffman code lookup table entry--this entry is four bytes for machines |
|
81 |
that have 16-bit pointers (e.g. PC's in the small or medium model). |
|
82 |
Valid extra bits are 0..13. e == 15 is EOB (end of block), e == 16 |
|
83 |
means that v is a literal, 16 < e < 32 means that v is a pointer to |
|
84 |
the next table, which codes e - 16 bits, and lastly e == 99 indicates |
|
85 |
an unused code. If a code with e == 99 is looked up, this implies an |
|
86 |
error in the data. */ |
|
87 |
struct huft { |
|
88 |
uchar e; /* number of extra bits or operation */ |
|
89 |
uchar b; /* number of bits in this code or subcode */ |
|
90 |
union { |
|
91 |
ushort n; /* literal, length base, or distance base */ |
|
92 |
struct huft *t; /* pointer to next level of table */ |
|
93 |
} v; |
|
94 |
}; |
|
95 |
||
96 |
%} |
|
97 |
! ! |
|
98 |
||
99 |
!ZipArchive primitiveVariables! |
|
100 |
%{ |
|
101 |
||
723 | 102 |
static int debugTrace = 0; |
103 |
||
636 | 104 |
/* |
105 |
* inflate variables |
|
106 |
*/ |
|
107 |
||
108 |
static unsigned char *inPtr; |
|
109 |
static unsigned char *outPtr; |
|
110 |
static unsigned char *slide; |
|
111 |
||
112 |
static int qflag = 0; |
|
113 |
||
114 |
/* The inflate algorithm uses a sliding 32K byte window on the uncompressed |
|
115 |
stream to find repeated byte strings. This is implemented here as a |
|
116 |
circular buffer. The index is updated simply by incrementing and then |
|
117 |
and'ing with 0x7fff (32K-1). */ |
|
118 |
/* It is left to other modules to supply the 32K area. It is assumed |
|
119 |
to be usable as if it were declared "uchar slide[32768];" or as just |
|
120 |
"uchar *slide;" and then malloc'ed in the latter case. The definition |
|
121 |
must be in unzip.h, included above. */ |
|
122 |
static unsigned wp; /* current position in slide */ |
|
123 |
||
124 |
||
125 |
/* Tables for deflate from PKZIP's appnote.txt. */ |
|
126 |
static unsigned border[] = { /* Order of the bit length code lengths */ |
|
1839 | 127 |
16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; |
636 | 128 |
|
129 |
static ushort cplens[] = { /* Copy lengths for literal codes 257..285 */ |
|
1839 | 130 |
3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, |
131 |
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; |
|
132 |
/* note: see note #13 above about the 258 in this list. */ |
|
636 | 133 |
|
134 |
static ushort cplext[] = { /* Extra bits for literal codes 257..285 */ |
|
1839 | 135 |
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, |
136 |
3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 99, 99}; /* 99==invalid */ |
|
636 | 137 |
|
138 |
static ushort cpdist[] = { /* Copy offsets for distance codes 0..29 */ |
|
1839 | 139 |
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, |
140 |
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, |
|
141 |
8193, 12289, 16385, 24577}; |
|
636 | 142 |
static ushort cpdext[] = { /* Extra bits for distance codes */ |
1839 | 143 |
0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, |
144 |
7, 7, 8, 8, 9, 9, 10, 10, 11, 11, |
|
145 |
12, 12, 13, 13}; |
|
636 | 146 |
|
147 |
/* And'ing with mask[n] masks the lower n bits */ |
|
148 |
static ushort mask[] = { |
|
149 |
0x0000, |
|
150 |
0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff, |
|
151 |
0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff |
|
152 |
}; |
|
153 |
||
154 |
||
155 |
/* Macros for inflate() bit peeking and grabbing. |
|
156 |
The usage is: |
|
157 |
||
1839 | 158 |
NEEDBITS(j) |
159 |
x = b & mask[j]; |
|
160 |
DUMPBITS(j) |
|
636 | 161 |
|
162 |
where NEEDBITS makes sure that b has at least j bits in it, and |
|
163 |
DUMPBITS removes the bits from b. The macros use the variable k |
|
164 |
for the number of bits in b. Normally, b and k are register |
|
165 |
variables for speed, and are initialized at the begining of a |
|
166 |
routine that uses these macros from a global bit buffer and count. |
|
167 |
||
168 |
In order to not ask for more bits than there are in the compressed |
|
169 |
stream, the Huffman tables are constructed to only ask for just |
|
170 |
enough bits to make up the end-of-block code (value 256). Then no |
|
171 |
bytes need to be "returned" to the buffer at the end of the last |
|
172 |
block. See the huft_build() routine. |
|
173 |
*/ |
|
174 |
||
175 |
static ulong bb; /* bit buffer */ |
|
176 |
static unsigned bk; /* bits in bit buffer */ |
|
177 |
||
637 | 178 |
#define NEEDBITS(n) { while(k<(n)){ b |= ((ulong)NEXTBYTE)<<k; k+=8; } } |
179 |
#define DUMPBITS(n) { b>>=(n); k-=(n); } |
|
636 | 180 |
|
181 |
||
182 |
/* |
|
183 |
Huffman code decoding is performed using a multi-level table lookup. |
|
184 |
The fastest way to decode is to simply build a lookup table whose |
|
185 |
size is determined by the longest code. However, the time it takes |
|
186 |
to build this table can also be a factor if the data being decoded |
|
187 |
is not very long. The most common codes are necessarily the |
|
188 |
shortest codes, so those codes dominate the decoding time, and hence |
|
189 |
the speed. The idea is you can have a shorter table that decodes the |
|
190 |
shorter, more probable codes, and then point to subsidiary tables for |
|
191 |
the longer codes. The time it costs to decode the longer codes is |
|
192 |
then traded against the time it takes to make longer tables. |
|
193 |
||
194 |
This results of this trade are in the variables lbits and dbits |
|
195 |
below. lbits is the number of bits the first level table for literal/ |
|
196 |
length codes can decode in one step, and dbits is the same thing for |
|
197 |
the distance codes. Subsequent tables are also less than or equal to |
|
198 |
those sizes. These values may be adjusted either when all of the |
|
199 |
codes are shorter than that, in which case the longest code length in |
|
200 |
bits is used, or when the shortest code is *longer* than the requested |
|
201 |
table size, in which case the length of the shortest code in bits is |
|
202 |
used. |
|
203 |
||
204 |
There are two different values for the two tables, since they code a |
|
205 |
different number of possibilities each. The literal/length table |
|
206 |
codes 286 possible values, or in a flat code, a little over eight |
|
207 |
bits. The distance table codes 30 possible values, or a little less |
|
208 |
than five bits, flat. The optimum values for speed end up being |
|
209 |
about one bit more than those, so lbits is 8+1 and dbits is 5+1. |
|
210 |
The optimum values may differ though from machine to machine, and |
|
211 |
possibly even between compilers. Your mileage may vary. |
|
212 |
*/ |
|
213 |
||
214 |
||
215 |
static int lbits = 9; /* bits in base literal/length lookup table */ |
|
216 |
static int dbits = 6; /* bits in base distance lookup table */ |
|
217 |
||
218 |
||
219 |
/* If BMAX needs to be larger than 16, then h and x[] should be ulong. */ |
|
220 |
#define BMAX 16 /* maximum bit length of any code (16 for explode) */ |
|
221 |
#define N_MAX 288 /* maximum number of codes in any set */ |
|
222 |
||
223 |
||
224 |
static unsigned hufts; /* track memory usage */ |
|
225 |
||
226 |
%} |
|
227 |
! ! |
|
228 |
||
229 |
!ZipArchive primitiveFunctions! |
|
230 |
%{ |
|
231 |
||
232 |
/* |
|
233 |
* inflate algorithm |
|
234 |
*/ |
|
235 |
||
236 |
/* Free the malloc'ed tables built by huft_build(), which makes a linked |
|
237 |
list of the tables it made, with the links in a dummy first entry of |
|
238 |
each table. */ |
|
1839 | 239 |
static int |
636 | 240 |
huft_free(t) |
241 |
struct huft *t; /* table to free */ |
|
242 |
{ |
|
243 |
register struct huft *p, *q; |
|
244 |
||
245 |
||
246 |
/* Go through linked list, freeing from the malloced (t[-1]) address. */ |
|
247 |
p = t; |
|
248 |
while (p != (struct huft *)NULL) |
|
249 |
{ |
|
250 |
q = (--p)->v.t; |
|
251 |
free(p); |
|
252 |
p = q; |
|
1839 | 253 |
} |
636 | 254 |
return 0; |
255 |
} |
|
256 |
||
257 |
||
258 |
||
259 |
||
260 |
/* Given a list of code lengths and a maximum table size, make a set of |
|
261 |
tables to decode that set of codes. Return zero on success, one if |
|
262 |
the given code set is incomplete (the tables are still built in this |
|
263 |
case), two if the input is invalid (all zero length codes or an |
|
264 |
oversubscribed set of lengths), and three if not enough memory. |
|
265 |
The code with value 256 is special, and the tables are constructed |
|
266 |
so that no bits beyond that code are fetched when that code is |
|
267 |
decoded. */ |
|
1839 | 268 |
static int |
636 | 269 |
huft_build(b, n, s, d, e, t, m) |
270 |
unsigned *b; /* code lengths in bits (all assumed <= BMAX) */ |
|
271 |
unsigned n; /* number of codes (assumed <= N_MAX) */ |
|
272 |
unsigned s; /* number of simple-valued codes (0..s-1) */ |
|
273 |
ushort *d; /* list of base values for non-simple codes */ |
|
274 |
ushort *e; /* list of extra bits for non-simple codes */ |
|
275 |
struct huft **t; /* result: starting table */ |
|
276 |
int *m; /* maximum lookup bits, returns actual */ |
|
277 |
{ |
|
278 |
unsigned a; /* counter for codes of length k */ |
|
279 |
unsigned c[BMAX+1]; /* bit length count table */ |
|
280 |
unsigned el; /* length of EOB code (value 256) */ |
|
281 |
unsigned f; /* i repeats in table every f entries */ |
|
282 |
int g; /* maximum code length */ |
|
283 |
int h; /* table level */ |
|
284 |
register unsigned i; /* counter, current code */ |
|
285 |
register unsigned j; /* counter */ |
|
286 |
register int k; /* number of bits in current code */ |
|
287 |
int lx[BMAX+1]; /* memory for l[-1..BMAX-1] */ |
|
288 |
int *l = lx+1; /* stack of bits per table */ |
|
289 |
register unsigned *p; /* pointer into c[], b[], or v[] */ |
|
290 |
register struct huft *q; /* points to current table */ |
|
291 |
struct huft r; /* table entry for structure assignment */ |
|
292 |
struct huft *u[BMAX]; /* table stack */ |
|
293 |
static unsigned v[N_MAX]; /* values in order of bit length */ |
|
294 |
register int w; /* bits before this table == (l * h) */ |
|
295 |
unsigned x[BMAX+1]; /* bit offsets, then code stack */ |
|
296 |
unsigned *xp; /* pointer into x */ |
|
297 |
int y; /* number of dummy codes added */ |
|
298 |
unsigned z; /* number of entries in current table */ |
|
1749 | 299 |
extern void *malloc(); |
636 | 300 |
|
301 |
/* Generate counts for each bit length */ |
|
302 |
el = n > 256 ? b[256] : BMAX; /* set length of EOB code, if any */ |
|
303 |
bzero((char *)c, sizeof(c)); |
|
304 |
p = b; i = n; |
|
305 |
do { |
|
306 |
c[*p]++; p++; /* assume all entries <= BMAX */ |
|
307 |
} while (--i); |
|
308 |
if (c[0] == n) /* null input--all zero length codes */ |
|
309 |
{ |
|
310 |
*t = (struct huft *)NULL; |
|
311 |
*m = 0; |
|
312 |
return 0; |
|
313 |
} |
|
314 |
||
315 |
||
316 |
/* Find minimum and maximum length, bound *m by those */ |
|
317 |
for (j = 1; j <= BMAX; j++) |
|
318 |
if (c[j]) |
|
319 |
break; |
|
320 |
k = j; /* minimum code length */ |
|
321 |
if ((unsigned)*m < j) |
|
322 |
*m = j; |
|
323 |
for (i = BMAX; i; i--) |
|
324 |
if (c[i]) |
|
325 |
break; |
|
326 |
g = i; /* maximum code length */ |
|
327 |
if ((unsigned)*m > i) |
|
328 |
*m = i; |
|
329 |
||
330 |
||
331 |
/* Adjust last length count to fill out codes, if needed */ |
|
332 |
for (y = 1 << j; j < i; j++, y <<= 1) |
|
333 |
if ((y -= c[j]) < 0) |
|
334 |
return 2; /* bad input: more codes than bits */ |
|
335 |
if ((y -= c[i]) < 0) |
|
336 |
return 2; |
|
337 |
c[i] += y; |
|
338 |
||
339 |
||
340 |
/* Generate starting offsets into the value table for each length */ |
|
341 |
x[1] = j = 0; |
|
342 |
p = c + 1; xp = x + 2; |
|
343 |
while (--i) { /* note that i == g from above */ |
|
344 |
*xp++ = (j += *p++); |
|
345 |
} |
|
346 |
||
347 |
||
348 |
/* Make a table of values in order of bit lengths */ |
|
349 |
p = b; i = 0; |
|
350 |
do { |
|
351 |
if ((j = *p++) != 0) |
|
352 |
v[x[j]++] = i; |
|
353 |
} while (++i < n); |
|
354 |
||
355 |
||
356 |
/* Generate the Huffman codes and for each, make the table entries */ |
|
357 |
x[0] = i = 0; /* first Huffman code is zero */ |
|
358 |
p = v; /* grab values in bit order */ |
|
359 |
h = -1; /* no tables yet--level -1 */ |
|
360 |
w = l[-1] = 0; /* no bits decoded yet */ |
|
361 |
u[0] = (struct huft *)NULL; /* just to keep compilers happy */ |
|
362 |
q = (struct huft *)NULL; /* ditto */ |
|
363 |
z = 0; /* ditto */ |
|
364 |
||
365 |
/* go through the bit lengths (k already is bits in shortest code) */ |
|
366 |
for (; k <= g; k++) |
|
367 |
{ |
|
368 |
a = c[k]; |
|
369 |
while (a--) |
|
370 |
{ |
|
371 |
/* here i is the Huffman code of length k bits for value *p */ |
|
372 |
/* make tables up to required level */ |
|
373 |
while (k > w + l[h]) |
|
374 |
{ |
|
1839 | 375 |
w += l[h++]; /* add bits already decoded */ |
636 | 376 |
|
1839 | 377 |
/* compute minimum size table less than or equal to *m bits */ |
378 |
z = (z = g - w) > (unsigned)*m ? *m : z; /* upper limit */ |
|
379 |
if ((f = 1 << (j = k - w)) > a + 1) /* try a k-w bit table */ |
|
380 |
{ /* too few codes for k-w bit table */ |
|
381 |
f -= a + 1; /* deduct codes from patterns left */ |
|
382 |
xp = c + k; |
|
383 |
while (++j < z) /* try smaller tables up to z bits */ |
|
384 |
{ |
|
385 |
if ((f <<= 1) <= *++xp) |
|
386 |
break; /* enough codes to use up j bits */ |
|
387 |
f -= *xp; /* else deduct codes from patterns */ |
|
388 |
} |
|
389 |
} |
|
390 |
if ((unsigned)w + j > el && (unsigned)w < el) |
|
391 |
j = el - w; /* make EOB code end at table */ |
|
392 |
z = 1 << j; /* table entries for j-bit table */ |
|
393 |
l[h] = j; /* set table size in stack */ |
|
636 | 394 |
|
1839 | 395 |
/* allocate and link in new table */ |
396 |
if ((q = (struct huft *)malloc((z + 1)*sizeof(struct huft))) == |
|
397 |
(struct huft *)NULL) |
|
398 |
{ |
|
399 |
if (h) |
|
400 |
huft_free(u[0]); |
|
401 |
return 3; /* not enough memory */ |
|
402 |
} |
|
403 |
hufts += z + 1; /* track memory usage */ |
|
404 |
*t = q + 1; /* link to list for huft_free() */ |
|
405 |
*(t = &(q->v.t)) = (struct huft *)NULL; |
|
406 |
u[h] = ++q; /* table starts after link */ |
|
636 | 407 |
|
1839 | 408 |
/* connect to last table, if there is one */ |
409 |
if (h) |
|
410 |
{ |
|
411 |
x[h] = i; /* save pattern for backing up */ |
|
412 |
r.b = (uchar)l[h-1]; /* bits to dump before this table */ |
|
413 |
r.e = (uchar)(16 + j); /* bits in this table */ |
|
414 |
r.v.t = q; /* pointer to this table */ |
|
415 |
j = (i & ((1 << w) - 1)) >> (w - l[h-1]); |
|
416 |
u[h-1][j] = r; /* connect to last table */ |
|
417 |
} |
|
636 | 418 |
} |
419 |
||
420 |
/* set up table entry in r */ |
|
421 |
r.b = (uchar)(k - w); |
|
422 |
if (p >= v + n) |
|
1839 | 423 |
r.e = 99; /* out of values--invalid code */ |
636 | 424 |
else if (*p < s) |
425 |
{ |
|
1839 | 426 |
r.e = (uchar)(*p < 256 ? 16 : 15); /* 256 is end-of-block code */ |
427 |
r.v.n = *p++; /* simple code is just the value */ |
|
636 | 428 |
} |
429 |
else |
|
430 |
{ |
|
1839 | 431 |
r.e = (uchar)e[*p - s]; /* non-simple--look up in lists */ |
432 |
r.v.n = d[*p++ - s]; |
|
636 | 433 |
} |
434 |
||
435 |
/* fill code-like entries with r */ |
|
436 |
f = 1 << (k - w); |
|
437 |
for (j = i >> w; j < z; j += f) |
|
1839 | 438 |
q[j] = r; |
636 | 439 |
|
440 |
/* backwards increment the k-bit code i */ |
|
441 |
for (j = 1 << (k - 1); i & j; j >>= 1) |
|
1839 | 442 |
i ^= j; |
636 | 443 |
i ^= j; |
444 |
||
445 |
/* backup over finished tables */ |
|
446 |
while ((i & ((1 << w) - 1)) != x[h]) |
|
1839 | 447 |
w -= l[--h]; /* don't need to update q */ |
636 | 448 |
} |
449 |
} |
|
450 |
||
451 |
||
452 |
/* return actual size of base table */ |
|
453 |
*m = l[0]; |
|
454 |
||
455 |
||
456 |
/* Return true (1) if we were given an incomplete table */ |
|
457 |
return y != 0 && g != 1; |
|
458 |
} |
|
459 |
||
460 |
||
461 |
||
462 |
#ifdef ASM_INFLATECODES |
|
463 |
# define inflate_codes(tl,td,bl,bd) flate_codes(tl,td,bl,bd,(uchar *)slide) |
|
464 |
int flate_codes OF((struct huft *, struct huft *, int, int, uchar *)); |
|
465 |
||
466 |
#else |
|
467 |
||
468 |
/* inflate (decompress) the codes in a deflated (compressed) block. |
|
469 |
Return an error code or zero if it all goes ok. */ |
|
1839 | 470 |
static int |
636 | 471 |
inflate_codes(tl, td, bl, bd) |
472 |
struct huft *tl, *td; /* literal/length and distance decoder tables */ |
|
473 |
int bl, bd; /* number of bits decoded by tl[] and td[] */ |
|
474 |
{ |
|
475 |
register unsigned e; /* table entry flag/number of extra bits */ |
|
476 |
unsigned n, d; /* length and index for copy */ |
|
477 |
unsigned w; /* current window position */ |
|
478 |
struct huft *t; /* pointer to table entry */ |
|
479 |
unsigned ml, md; /* masks for bl and bd bits */ |
|
480 |
register ulong b; /* bit buffer */ |
|
481 |
register unsigned k; /* number of bits in bit buffer */ |
|
482 |
||
483 |
||
484 |
/* make local copies of globals */ |
|
485 |
b = bb; /* initialize bit buffer */ |
|
486 |
k = bk; |
|
487 |
w = wp; /* initialize window position */ |
|
488 |
||
489 |
||
490 |
/* inflate the coded data */ |
|
491 |
ml = mask[bl]; /* precompute masks for speed */ |
|
492 |
md = mask[bd]; |
|
493 |
while (1) /* do until end of block */ |
|
494 |
{ |
|
495 |
NEEDBITS((unsigned)bl) |
|
496 |
if ((e = (t = tl + ((unsigned)b & ml))->e) > 16) |
|
497 |
do { |
|
1839 | 498 |
if (e == 99) |
499 |
return 1; |
|
500 |
DUMPBITS(t->b) |
|
501 |
e -= 16; |
|
502 |
NEEDBITS(e) |
|
636 | 503 |
} while ((e = (t = t->v.t + ((unsigned)b & mask[e]))->e) > 16); |
504 |
DUMPBITS(t->b) |
|
505 |
if (e == 16) /* then it's a literal */ |
|
506 |
{ |
|
507 |
slide[w++] = (uchar)t->v.n; |
|
508 |
if (w == WSIZE) |
|
509 |
{ |
|
1839 | 510 |
FLUSH(w); |
511 |
w = 0; |
|
636 | 512 |
} |
513 |
} |
|
514 |
else /* it's an EOB or a length */ |
|
515 |
{ |
|
516 |
/* exit if end of block */ |
|
517 |
if (e == 15) |
|
1839 | 518 |
break; |
636 | 519 |
|
520 |
/* get length of block to copy */ |
|
521 |
NEEDBITS(e) |
|
522 |
n = t->v.n + ((unsigned)b & mask[e]); |
|
523 |
DUMPBITS(e); |
|
524 |
||
525 |
/* decode distance of block to copy */ |
|
526 |
NEEDBITS((unsigned)bd) |
|
527 |
if ((e = (t = td + ((unsigned)b & md))->e) > 16) |
|
1839 | 528 |
do { |
529 |
if (e == 99) |
|
530 |
return 1; |
|
531 |
DUMPBITS(t->b) |
|
532 |
e -= 16; |
|
533 |
NEEDBITS(e) |
|
534 |
} while ((e = (t = t->v.t + ((unsigned)b & mask[e]))->e) > 16); |
|
636 | 535 |
DUMPBITS(t->b) |
536 |
NEEDBITS(e) |
|
537 |
d = w - t->v.n - ((unsigned)b & mask[e]); |
|
538 |
DUMPBITS(e) |
|
539 |
||
540 |
/* do the copy */ |
|
541 |
do { |
|
1839 | 542 |
n -= (e = (e = WSIZE - ((d &= WSIZE-1) > w ? d : w)) > n ? n : e); |
636 | 543 |
#ifndef NOMEMCPY |
1839 | 544 |
if (w - d >= e) /* (this test assumes unsigned comparison) */ |
545 |
{ |
|
636 | 546 |
# ifdef USE_MEMCPY |
1839 | 547 |
memcpy(slide + w, slide + d, e); |
636 | 548 |
# else |
1839 | 549 |
bcopy(slide + d, slide + w, e); |
636 | 550 |
# endif |
1839 | 551 |
w += e; |
552 |
d += e; |
|
553 |
} |
|
554 |
else /* do it slow to avoid memcpy() overlap */ |
|
636 | 555 |
#endif /* !NOMEMCPY */ |
1839 | 556 |
do { |
557 |
slide[w++] = slide[d++]; |
|
558 |
} while (--e); |
|
559 |
if (w == WSIZE) |
|
560 |
{ |
|
561 |
FLUSH(w); |
|
562 |
w = 0; |
|
563 |
} |
|
636 | 564 |
} while (n); |
565 |
} |
|
566 |
} |
|
567 |
||
568 |
||
569 |
/* restore the globals from the locals */ |
|
570 |
wp = w; /* restore global window pointer */ |
|
571 |
bb = b; /* restore global bit buffer */ |
|
572 |
bk = k; |
|
573 |
||
574 |
||
575 |
/* done */ |
|
576 |
return 0; |
|
577 |
} |
|
578 |
||
579 |
#endif /* ASM_INFLATECODES */ |
|
580 |
||
581 |
||
582 |
||
583 |
/* "decompress" an inflated type 0 (stored) block. */ |
|
1839 | 584 |
static int |
636 | 585 |
inflate_stored() |
586 |
{ |
|
587 |
unsigned n; /* number of bytes in block */ |
|
588 |
unsigned w; /* current window position */ |
|
589 |
register ulong b; /* bit buffer */ |
|
590 |
register unsigned k; /* number of bits in bit buffer */ |
|
591 |
||
592 |
||
593 |
/* make local copies of globals */ |
|
594 |
Trace((stderr, "stored block\n")); |
|
595 |
b = bb; /* initialize bit buffer */ |
|
596 |
k = bk; |
|
597 |
w = wp; /* initialize window position */ |
|
598 |
||
599 |
||
600 |
/* go to byte boundary */ |
|
601 |
n = k & 7; |
|
602 |
DUMPBITS(n); |
|
603 |
||
604 |
||
605 |
/* get the length and its complement */ |
|
606 |
NEEDBITS(16) |
|
607 |
n = ((unsigned)b & 0xffff); |
|
608 |
DUMPBITS(16) |
|
609 |
NEEDBITS(16) |
|
610 |
if (n != (unsigned)((~b) & 0xffff)) |
|
611 |
return 1; /* error in compressed data */ |
|
612 |
DUMPBITS(16) |
|
613 |
||
614 |
||
615 |
/* read and output the compressed data */ |
|
616 |
while (n--) |
|
617 |
{ |
|
618 |
NEEDBITS(8) |
|
619 |
slide[w++] = (uchar)b; |
|
620 |
if (w == WSIZE) |
|
621 |
{ |
|
622 |
FLUSH(w); |
|
623 |
w = 0; |
|
624 |
} |
|
625 |
DUMPBITS(8) |
|
626 |
} |
|
627 |
||
628 |
||
629 |
/* restore the globals from the locals */ |
|
630 |
wp = w; /* restore global window pointer */ |
|
631 |
bb = b; /* restore global bit buffer */ |
|
632 |
bk = k; |
|
633 |
return 0; |
|
634 |
} |
|
635 |
||
636 |
||
637 |
/* Globals for literal tables (built once) */ |
|
638 |
static struct huft *fixed_tl = (struct huft *)NULL; |
|
639 |
static struct huft *fixed_td = (struct huft *)NULL; |
|
640 |
static int fixed_bl, fixed_bd; |
|
641 |
||
642 |
/* decompress an inflated type 1 (fixed Huffman codes) block. We should |
|
643 |
either replace this with a custom decoder, or at least precompute the |
|
644 |
Huffman tables. */ |
|
1839 | 645 |
static int |
636 | 646 |
inflate_fixed() |
647 |
{ |
|
648 |
/* if first time, set up tables for fixed blocks */ |
|
649 |
Trace((stderr, "fixed block\n")); |
|
650 |
if (fixed_tl == (struct huft *)NULL) |
|
651 |
{ |
|
652 |
int i; /* temporary variable */ |
|
653 |
static unsigned l[288]; /* length list for huft_build */ |
|
654 |
||
655 |
/* literal table */ |
|
656 |
for (i = 0; i < 144; i++) |
|
657 |
l[i] = 8; |
|
658 |
for (; i < 256; i++) |
|
659 |
l[i] = 9; |
|
660 |
for (; i < 280; i++) |
|
661 |
l[i] = 7; |
|
662 |
for (; i < 288; i++) /* make a complete, but wrong code set */ |
|
663 |
l[i] = 8; |
|
664 |
fixed_bl = 7; |
|
665 |
if ((i = huft_build(l, 288, 257, cplens, cplext, |
|
1839 | 666 |
&fixed_tl, &fixed_bl)) != 0) |
636 | 667 |
{ |
668 |
Trace((stderr, "incomplete code set 1\n")); |
|
669 |
fixed_tl = (struct huft *)NULL; |
|
670 |
return i; |
|
671 |
} |
|
672 |
||
673 |
/* distance table */ |
|
674 |
for (i = 0; i < 30; i++) /* make an incomplete code set */ |
|
675 |
l[i] = 5; |
|
676 |
fixed_bd = 5; |
|
677 |
if ((i = huft_build(l, 30, 0, cpdist, cpdext, &fixed_td, &fixed_bd)) > 1) |
|
678 |
{ |
|
679 |
Trace((stderr, "incomplete code set 2\n")); |
|
680 |
huft_free(fixed_tl); |
|
681 |
fixed_tl = (struct huft *)NULL; |
|
682 |
return i; |
|
683 |
} |
|
684 |
} |
|
685 |
||
686 |
||
687 |
/* decompress until an end-of-block code */ |
|
688 |
return inflate_codes(fixed_tl, fixed_td, fixed_bl, fixed_bd) != 0; |
|
689 |
} |
|
690 |
||
691 |
||
692 |
||
693 |
/* decompress an inflated type 2 (dynamic Huffman codes) block. */ |
|
1839 | 694 |
static int |
636 | 695 |
inflate_dynamic() |
696 |
{ |
|
697 |
int i; /* temporary variables */ |
|
698 |
unsigned j; |
|
699 |
unsigned l; /* last length */ |
|
700 |
unsigned m; /* mask for bit lengths table */ |
|
701 |
unsigned n; /* number of lengths to get */ |
|
702 |
struct huft *tl; /* literal/length code table */ |
|
703 |
struct huft *td; /* distance code table */ |
|
704 |
int bl; /* lookup bits for tl */ |
|
705 |
int bd; /* lookup bits for td */ |
|
706 |
unsigned nb; /* number of bit length codes */ |
|
707 |
unsigned nl; /* number of literal/length codes */ |
|
708 |
unsigned nd; /* number of distance codes */ |
|
709 |
#ifdef PKZIP_BUG_WORKAROUND |
|
710 |
static unsigned ll[288+32]; /* literal/length and distance code lengths */ |
|
711 |
#else |
|
712 |
static unsigned ll[286+30]; /* literal/length and distance code lengths */ |
|
713 |
#endif |
|
714 |
register ulong b; /* bit buffer */ |
|
715 |
register unsigned k; /* number of bits in bit buffer */ |
|
716 |
||
717 |
||
718 |
/* make local bit buffer */ |
|
719 |
Trace((stderr, "dynamic block\n")); |
|
720 |
b = bb; |
|
721 |
k = bk; |
|
722 |
||
723 |
||
724 |
/* read in table lengths */ |
|
725 |
NEEDBITS(5) |
|
726 |
nl = 257 + ((unsigned)b & 0x1f); /* number of literal/length codes */ |
|
727 |
DUMPBITS(5) |
|
728 |
NEEDBITS(5) |
|
729 |
nd = 1 + ((unsigned)b & 0x1f); /* number of distance codes */ |
|
730 |
DUMPBITS(5) |
|
731 |
NEEDBITS(4) |
|
732 |
nb = 4 + ((unsigned)b & 0xf); /* number of bit length codes */ |
|
733 |
DUMPBITS(4) |
|
734 |
#ifdef PKZIP_BUG_WORKAROUND |
|
735 |
if (nl > 288 || nd > 32) |
|
736 |
#else |
|
737 |
if (nl > 286 || nd > 30) |
|
738 |
#endif |
|
739 |
{ |
|
740 |
Trace((stderr, "bad length\n")); |
|
741 |
return 1; /* bad lengths */ |
|
742 |
} |
|
743 |
||
744 |
||
745 |
/* read in bit-length-code lengths */ |
|
746 |
for (j = 0; j < nb; j++) |
|
747 |
{ |
|
748 |
NEEDBITS(3) |
|
749 |
ll[border[j]] = (unsigned)b & 7; |
|
750 |
DUMPBITS(3) |
|
751 |
} |
|
752 |
for (; j < 19; j++) |
|
753 |
ll[border[j]] = 0; |
|
754 |
||
755 |
||
756 |
/* build decoding table for trees--single level, 7 bit lookup */ |
|
757 |
bl = 7; |
|
758 |
if ((i = huft_build(ll, 19, 19, NULL, NULL, &tl, &bl)) != 0) |
|
759 |
{ |
|
760 |
if (i == 1) |
|
761 |
huft_free(tl); |
|
762 |
Trace((stderr, "incomplete code set 3\n")); |
|
763 |
return i; /* incomplete code set */ |
|
764 |
} |
|
765 |
||
766 |
||
767 |
/* read in literal and distance code lengths */ |
|
768 |
n = nl + nd; |
|
769 |
m = mask[bl]; |
|
770 |
i = l = 0; |
|
771 |
while ((unsigned)i < n) |
|
772 |
{ |
|
773 |
NEEDBITS((unsigned)bl) |
|
774 |
j = (td = tl + ((unsigned)b & m))->b; |
|
775 |
DUMPBITS(j) |
|
776 |
j = td->v.n; |
|
777 |
if (j < 16) /* length of code in bits (0..15) */ |
|
778 |
ll[i++] = l = j; /* save last length in l */ |
|
779 |
else if (j == 16) /* repeat last length 3 to 6 times */ |
|
780 |
{ |
|
781 |
NEEDBITS(2) |
|
782 |
j = 3 + ((unsigned)b & 3); |
|
783 |
DUMPBITS(2) |
|
784 |
if ((unsigned)i + j > n) |
|
1839 | 785 |
return 1; |
636 | 786 |
while (j--) |
1839 | 787 |
ll[i++] = l; |
636 | 788 |
} |
789 |
else if (j == 17) /* 3 to 10 zero length codes */ |
|
790 |
{ |
|
791 |
NEEDBITS(3) |
|
792 |
j = 3 + ((unsigned)b & 7); |
|
793 |
DUMPBITS(3) |
|
794 |
if ((unsigned)i + j > n) |
|
1839 | 795 |
return 1; |
636 | 796 |
while (j--) |
1839 | 797 |
ll[i++] = 0; |
636 | 798 |
l = 0; |
799 |
} |
|
800 |
else /* j == 18: 11 to 138 zero length codes */ |
|
801 |
{ |
|
802 |
NEEDBITS(7) |
|
803 |
j = 11 + ((unsigned)b & 0x7f); |
|
804 |
DUMPBITS(7) |
|
805 |
if ((unsigned)i + j > n) |
|
1839 | 806 |
return 1; |
636 | 807 |
while (j--) |
1839 | 808 |
ll[i++] = 0; |
636 | 809 |
l = 0; |
810 |
} |
|
811 |
} |
|
812 |
||
813 |
||
814 |
/* free decoding table for trees */ |
|
815 |
huft_free(tl); |
|
816 |
||
817 |
||
818 |
/* restore the global bit buffer */ |
|
819 |
bb = b; |
|
820 |
bk = k; |
|
821 |
||
822 |
||
823 |
/* build the decoding tables for literal/length and distance codes */ |
|
824 |
bl = lbits; |
|
825 |
if ((i = huft_build(ll, nl, 257, cplens, cplext, &tl, &bl)) != 0) |
|
826 |
{ |
|
827 |
Trace((stderr, "incomplete code set 4\n")); |
|
828 |
if (i == 1 && !qflag) { |
|
829 |
Trace((stderr, "incomplete l-tree\n")); |
|
830 |
huft_free(tl); |
|
831 |
} |
|
832 |
return i; /* incomplete code set */ |
|
833 |
} |
|
834 |
bd = dbits; |
|
835 |
if ((i = huft_build(ll + nl, nd, 0, cpdist, cpdext, &td, &bd)) != 0) |
|
836 |
{ |
|
837 |
Trace((stderr, "huft_build err\n")); |
|
838 |
if (i == 1 && !qflag) { |
|
839 |
Trace((stderr, "incomplete d-tree\n")); |
|
840 |
#ifdef PKZIP_BUG_WORKAROUND |
|
841 |
i = 0; |
|
842 |
} |
|
843 |
#else |
|
844 |
huft_free(td); |
|
845 |
} |
|
846 |
huft_free(tl); |
|
847 |
return i; /* incomplete code set */ |
|
848 |
#endif |
|
849 |
} |
|
850 |
||
851 |
||
852 |
/* decompress until an end-of-block code */ |
|
853 |
if (inflate_codes(tl, td, bl, bd)) { |
|
854 |
Trace((stderr, "inflate_codes error\n")); |
|
855 |
return 1; |
|
856 |
} |
|
857 |
||
858 |
||
859 |
/* free the decoding tables, return */ |
|
860 |
huft_free(tl); |
|
861 |
huft_free(td); |
|
862 |
Trace((stderr, "block ok\n")); |
|
863 |
return 0; |
|
864 |
} |
|
865 |
||
866 |
||
867 |
||
868 |
/* decompress an inflated block */ |
|
1839 | 869 |
static int |
637 | 870 |
inflate_block(endPtr) |
871 |
int *endPtr; /* last block flag */ |
|
636 | 872 |
{ |
873 |
unsigned t; /* block type */ |
|
874 |
register ulong b; /* bit buffer */ |
|
875 |
register unsigned k; /* number of bits in bit buffer */ |
|
876 |
||
877 |
||
637 | 878 |
Trace((stderr, "inflate_block\n")); |
879 |
||
636 | 880 |
/* make local bit buffer */ |
881 |
b = bb; |
|
882 |
k = bk; |
|
883 |
||
884 |
||
885 |
/* read in last block bit */ |
|
886 |
NEEDBITS(1) |
|
637 | 887 |
*endPtr = (int)b & 1; |
888 |
Trace((stderr, " end = %d\n", (int)b & 1)); |
|
889 |
||
636 | 890 |
DUMPBITS(1) |
891 |
||
892 |
||
893 |
/* read in block type */ |
|
894 |
NEEDBITS(2) |
|
895 |
t = (unsigned)b & 3; |
|
896 |
DUMPBITS(2) |
|
637 | 897 |
Trace((stderr, " type = %d\n", t)); |
636 | 898 |
|
899 |
||
900 |
/* restore the global bit buffer */ |
|
901 |
bb = b; |
|
902 |
bk = k; |
|
903 |
||
904 |
||
905 |
/* inflate that block type */ |
|
637 | 906 |
if (t == 2) { |
636 | 907 |
return inflate_dynamic(); |
637 | 908 |
} |
909 |
if (t == 0) { |
|
636 | 910 |
return inflate_stored(); |
637 | 911 |
} |
912 |
if (t == 1) { |
|
636 | 913 |
return inflate_fixed(); |
637 | 914 |
} |
636 | 915 |
|
916 |
Trace((stderr, "bad block type\n")); |
|
917 |
/* bad block type */ |
|
918 |
return 2; |
|
919 |
} |
|
920 |
||
921 |
||
922 |
||
923 |
/* decompress an inflated entry */ |
|
1839 | 924 |
static int |
636 | 925 |
inflate() |
926 |
{ |
|
637 | 927 |
int endFlag; /* last block flag */ |
636 | 928 |
int r; /* result code */ |
929 |
unsigned h; /* maximum struct huft's malloc'ed */ |
|
930 |
||
931 |
/* initialize window, bit buffer */ |
|
932 |
wp = 0; |
|
933 |
bk = 0; |
|
934 |
bb = 0; |
|
935 |
||
637 | 936 |
endFlag = 0; |
636 | 937 |
|
938 |
/* decompress until the last block */ |
|
939 |
h = 0; |
|
940 |
do { |
|
941 |
hufts = 0; |
|
637 | 942 |
if ((r = inflate_block(&endFlag)) != 0) { |
943 |
Trace((stderr, "inflate_block -> %d\n", r)); |
|
636 | 944 |
return r; |
637 | 945 |
} |
636 | 946 |
if (hufts > h) |
947 |
h = hufts; |
|
637 | 948 |
} while (!endFlag); |
636 | 949 |
|
950 |
||
951 |
/* flush out slide */ |
|
952 |
FLUSH(wp); |
|
953 |
||
954 |
||
955 |
/* return success */ |
|
956 |
Trace((stderr, "%u bytes in Huffman tables (%d/entry)\n", |
|
1839 | 957 |
h * sizeof(struct huft), sizeof(struct huft))); |
636 | 958 |
return 0; |
959 |
} |
|
960 |
||
961 |
||
962 |
||
1839 | 963 |
static int |
636 | 964 |
inflate_free() |
965 |
{ |
|
966 |
if (fixed_td != (struct huft *)NULL) |
|
967 |
{ |
|
968 |
huft_free(fixed_td); |
|
969 |
fixed_td = (struct huft *)NULL; |
|
970 |
} |
|
971 |
||
972 |
if (fixed_tl != (struct huft *)NULL) |
|
973 |
{ |
|
974 |
huft_free(fixed_tl); |
|
975 |
fixed_tl = (struct huft *)NULL; |
|
976 |
} |
|
977 |
return 0; |
|
978 |
} |
|
979 |
||
980 |
||
1839 | 981 |
static int |
636 | 982 |
stx_inflate(in, out) |
983 |
char *in, *out; |
|
984 |
{ |
|
985 |
int rslt; |
|
1749 | 986 |
extern void *malloc(); |
636 | 987 |
|
988 |
inPtr = in; |
|
989 |
outPtr = out; |
|
1564 | 990 |
slide = malloc(WSIZE+2); |
637 | 991 |
if (! slide) return 1; |
636 | 992 |
|
993 |
rslt = inflate(); |
|
994 |
inflate_free(); |
|
637 | 995 |
free(slide); |
636 | 996 |
return rslt; |
997 |
} |
|
998 |
||
999 |
%} |
|
1000 |
! ! |
|
1001 |
||
622 | 1002 |
!ZipArchive class methodsFor:'documentation'! |
1003 |
||
1839 | 1004 |
copyright |
624 | 1005 |
" |
1006 |
COPYRIGHT (c) 1998 by eXept Software AG |
|
1839 | 1007 |
All Rights Reserved |
624 | 1008 |
|
1009 |
This software is furnished under a license and may be used |
|
1010 |
only in accordance with the terms of that license and with the |
|
1011 |
inclusion of the above copyright notice. This software may not |
|
1012 |
be provided or otherwise made available to, or used by, any |
|
1013 |
other person. No title to or ownership of the software is |
|
1014 |
hereby transferred. |
|
1015 |
" |
|
1016 |
||
1017 |
! |
|
622 | 1018 |
|
624 | 1019 |
documentation |
1020 |
" |
|
1021 |
provides access to a zip archive. |
|
1820 | 1022 |
Caveat: the only compression method (for now) is deflate. |
651 | 1023 |
|
1024 |
[author:] |
|
1839 | 1025 |
Claus Gittinger |
624 | 1026 |
" |
1027 |
! |
|
1028 |
||
1029 |
examples |
|
1030 |
" |
|
1839 | 1031 |
[exBegin] |
624 | 1032 |
|zip bytes| |
1033 |
||
1034 |
zip := ZipArchive oldFileNamed:'foo.zip'. |
|
1035 |
bytes := zip extract:'bar'. |
|
1839 | 1036 |
[exEnd] |
636 | 1037 |
|
1839 | 1038 |
[exBegin] |
636 | 1039 |
|zip bytes| |
1040 |
||
1041 |
zip := ZipArchive oldFileNamed:'source/stx/libbasic2.zip'. |
|
1042 |
zip entries do:[:entry | |
|
1839 | 1043 |
Transcript showCR:entry |
636 | 1044 |
]. |
1839 | 1045 |
[exEnd] |
636 | 1046 |
|
1839 | 1047 |
[exBegin] |
636 | 1048 |
|zip bytes| |
1049 |
||
1050 |
zip := ZipArchive oldFileNamed:'source/stx/libbasic2.zip'. |
|
1051 |
bytes := zip extract:'TwoByteStr.st'. |
|
1052 |
Transcript showCR:(bytes asString). |
|
1839 | 1053 |
[exEnd] |
624 | 1054 |
" |
1979 | 1055 |
! |
1056 |
||
1057 |
examples_zipReadWriteTests |
|
1058 |
" |
|
1059 |
||
1060 |
|ziprd zipwr entryDict| |
|
1061 |
||
1062 |
ziprd := ZipArchive oldFileNamed:'C:\Dokumente und Einstellungen\stefan\Eigene Dateien\tmp\projects.zip'. |
|
1063 |
entryDict := Dictionary new. |
|
1064 |
ziprd entries do: [:aFileName| |
|
1065 |
entryDict at: aFileName put: (ziprd extract: aFileName) asString. |
|
1066 |
]. |
|
1067 |
||
1068 |
zipwr := ZipArchive newFileNamed:'C:\Dokumente und Einstellungen\stefan\Eigene Dateien\tmp\projects_expecco_test.zip'. |
|
1069 |
entryDict keysAndValuesDo: [:key :value| |
|
1070 |
zipwr addFile: key withContents: value compressMethod: 8 asDirectory: (value size == 0). |
|
1071 |
]. |
|
1072 |
zipwr addCentralZipDirectory. |
|
1073 |
-------------------------------------------------------------------------------- |
|
1074 |
|zipwr| |
|
1075 |
||
1076 |
zipwr := ZipArchive newFileNamed:'C:\Dokumente und Einstellungen\stefan\Eigene Dateien\tmp\crcTest_expecco_test.zip'. |
|
1077 |
||
1078 |
zipwr addFile:'FastInflateStream.st' |
|
1079 |
withContents: (Filename named: 'C:\Dokumente und Einstellungen\stefan\Eigene Dateien\tmp\crcTest.txt') contents asString |
|
1080 |
compressMethod: 8 |
|
1081 |
asDirectory: false. |
|
1082 |
||
1083 |
zipwr addCentralZipDirectory. |
|
1084 |
------------------------------------------------------------------------------- |
|
1085 |
|zipwr| |
|
1086 |
||
1087 |
zipwr := ZipArchive newFileNamed:'C:\Dokumente und Einstellungen\stefan\Eigene Dateien\tmp\FastInflateStream_expecco_test.zip'. |
|
1088 |
||
1089 |
zipwr addFile:'FastInflateStream.st' |
|
1090 |
withContents: (Filename named: 'C:\Dokumente und Einstellungen\stefan\Eigene Dateien\tmp\FastInflateStream.st') contents asString |
|
1091 |
compressMethod: 8 |
|
1092 |
asDirectory: false. |
|
1093 |
||
1094 |
zipwr addCentralZipDirectory. |
|
1095 |
||
1096 |
" |
|
1097 |
! |
|
1098 |
||
1099 |
fileFormatDescription |
|
1100 |
||
1101 |
"/File: APPNOTE.TXT - .ZIP File Format Specification |
|
1102 |
"/Version: 6.3.2 |
|
1103 |
"/Revised: September 28, 2007 |
|
1104 |
"/Copyright (c) 1989 - 2007 PKWARE Inc., All Rights Reserved. |
|
1105 |
"/ |
|
1106 |
"/The use of certain technological aspects disclosed in the current |
|
1107 |
"/APPNOTE is available pursuant to the below section entitled |
|
1108 |
"/"Incorporating PKWARE Proprietary Technology into Your Product". |
|
1109 |
"/ |
|
1110 |
"/I. Purpose |
|
1111 |
"/---------- |
|
1112 |
"/ |
|
1113 |
"/This specification is intended to define a cross-platform, |
|
1114 |
"/interoperable file storage and transfer format. Since its |
|
1115 |
"/first publication in 1989, PKWARE has remained committed to |
|
1116 |
"/ensuring the interoperability of the .ZIP file format through |
|
1117 |
"/publication and maintenance of this specification. We trust that |
|
1118 |
"/all .ZIP compatible vendors and application developers that have |
|
1119 |
"/adopted and benefited from this format will share and support |
|
1120 |
"/this commitment to interoperability. |
|
1121 |
"/ |
|
1122 |
"/II. Contacting PKWARE |
|
1123 |
"/--------------------- |
|
1124 |
"/ |
|
1125 |
"/ PKWARE, Inc. |
|
1126 |
"/ 648 N. Plankinton Avenue, Suite 220 |
|
1127 |
"/ Milwaukee, WI 53203 |
|
1128 |
"/ +1-414-289-9788 |
|
1129 |
"/ +1-414-289-9789 FAX |
|
1130 |
"/ zipformat@pkware.com |
|
1131 |
"/ |
|
1132 |
"/III. Disclaimer |
|
1133 |
"/--------------- |
|
1134 |
"/ |
|
1135 |
"/Although PKWARE will attempt to supply current and accurate |
|
1136 |
"/information relating to its file formats, algorithms, and the |
|
1137 |
"/subject programs, the possibility of error or omission cannot |
|
1138 |
"/be eliminated. PKWARE therefore expressly disclaims any warranty |
|
1139 |
"/that the information contained in the associated materials relating |
|
1140 |
"/to the subject programs and/or the format of the files created or |
|
1141 |
"/accessed by the subject programs and/or the algorithms used by |
|
1142 |
"/the subject programs, or any other matter, is current, correct or |
|
1143 |
"/accurate as delivered. Any risk of damage due to any possible |
|
1144 |
"/inaccurate information is assumed by the user of the information. |
|
1145 |
"/Furthermore, the information relating to the subject programs |
|
1146 |
"/and/or the file formats created or accessed by the subject |
|
1147 |
"/programs and/or the algorithms used by the subject programs is |
|
1148 |
"/subject to change without notice. |
|
1149 |
"/ |
|
1150 |
"/If the version of this file is marked as a NOTIFICATION OF CHANGE, |
|
1151 |
"/the content defines an Early Feature Specification (EFS) change |
|
1152 |
"/to the .ZIP file format that may be subject to modification prior |
|
1153 |
"/to publication of the Final Feature Specification (FFS). This |
|
1154 |
"/document may also contain information on Planned Feature |
|
1155 |
"/Specifications (PFS) defining recognized future extensions. |
|
1156 |
"/ |
|
1157 |
"/IV. Change Log |
|
1158 |
"/-------------- |
|
1159 |
"/ |
|
1160 |
"/Version Change Description Date |
|
1161 |
"/------- ------------------ ---------- |
|
1162 |
"/5.2 -Single Password Symmetric Encryption 06/02/2003 |
|
1163 |
"/ storage |
|
1164 |
"/ |
|
1165 |
"/6.1.0 -Smartcard compatibility 01/20/2004 |
|
1166 |
"/ -Documentation on certificate storage |
|
1167 |
"/ |
|
1168 |
"/6.2.0 -Introduction of Central Directory 04/26/2004 |
|
1169 |
"/ Encryption for encrypting metadata |
|
1170 |
"/ -Added OS/X to Version Made By values |
|
1171 |
"/ |
|
1172 |
"/6.2.1 -Added Extra Field placeholder for 04/01/2005 |
|
1173 |
"/ POSZIP using ID 0x4690 |
|
1174 |
"/ |
|
1175 |
"/ -Clarified size field on |
|
1176 |
"/ "zip64 end of central directory record" |
|
1177 |
"/ |
|
1178 |
"/6.2.2 -Documented Final Feature Specification 01/06/2006 |
|
1179 |
"/ for Strong Encryption |
|
1180 |
"/ |
|
1181 |
"/ -Clarifications and typographical |
|
1182 |
"/ corrections |
|
1183 |
"/ |
|
1184 |
"/6.3.0 -Added tape positioning storage 09/29/2006 |
|
1185 |
"/ parameters |
|
1186 |
"/ |
|
1187 |
"/ -Expanded list of supported hash algorithms |
|
1188 |
"/ |
|
1189 |
"/ -Expanded list of supported compression |
|
1190 |
"/ algorithms |
|
1191 |
"/ |
|
1192 |
"/ -Expanded list of supported encryption |
|
1193 |
"/ algorithms |
|
1194 |
"/ |
|
1195 |
"/ -Added option for Unicode filename |
|
1196 |
"/ storage |
|
1197 |
"/ |
|
1198 |
"/ -Clarifications for consistent use |
|
1199 |
"/ of Data Descriptor records |
|
1200 |
"/ |
|
1201 |
"/ -Added additional "Extra Field" |
|
1202 |
"/ definitions |
|
1203 |
"/ |
|
1204 |
"/6.3.1 -Corrected standard hash values for 04/11/2007 |
|
1205 |
"/ SHA-256/384/512 |
|
1206 |
"/ |
|
1207 |
"/6.3.2 -Added compression method 97 09/28/2007 |
|
1208 |
"/ |
|
1209 |
"/ -Documented InfoZIP "Extra Field" |
|
1210 |
"/ values for UTF-8 file name and |
|
1211 |
"/ file comment storage |
|
1212 |
"/ |
|
1213 |
"/V. General Format of a .ZIP file |
|
1214 |
"/-------------------------------- |
|
1215 |
"/ |
|
1216 |
"/ Files stored in arbitrary order. Large .ZIP files can span multiple |
|
1217 |
"/ volumes or be split into user-defined segment sizes. All values |
|
1218 |
"/ are stored in little-endian byte order unless otherwise specified. |
|
1219 |
"/ |
|
1220 |
"/ Overall .ZIP file format: |
|
1221 |
"/ |
|
1222 |
"/ [local file header 1] |
|
1223 |
"/ [file data 1] |
|
1224 |
"/ [data descriptor 1] |
|
1225 |
"/ . |
|
1226 |
"/ . |
|
1227 |
"/ . |
|
1228 |
"/ [local file header n] |
|
1229 |
"/ [file data n] |
|
1230 |
"/ [data descriptor n] |
|
1231 |
"/ [archive decryption header] |
|
1232 |
"/ [archive extra data record] |
|
1233 |
"/ [central directory] |
|
1234 |
"/ [zip64 end of central directory record] |
|
1235 |
"/ [zip64 end of central directory locator] |
|
1236 |
"/ [end of central directory record] |
|
1237 |
"/ |
|
1238 |
"/ |
|
1239 |
"/ A. Local file header: |
|
1240 |
"/ |
|
1241 |
"/ local file header signature 4 bytes (0x04034b50) |
|
1242 |
"/ version needed to extract 2 bytes |
|
1243 |
"/ general purpose bit flag 2 bytes |
|
1244 |
"/ compression method 2 bytes |
|
1245 |
"/ last mod file time 2 bytes |
|
1246 |
"/ last mod file date 2 bytes |
|
1247 |
"/ crc-32 4 bytes |
|
1248 |
"/ compressed size 4 bytes |
|
1249 |
"/ uncompressed size 4 bytes |
|
1250 |
"/ file name length 2 bytes |
|
1251 |
"/ extra field length 2 bytes |
|
1252 |
"/ |
|
1253 |
"/ file name (variable size) |
|
1254 |
"/ extra field (variable size) |
|
1255 |
"/ |
|
1256 |
"/ B. File data |
|
1257 |
"/ |
|
1258 |
"/ Immediately following the local header for a file |
|
1259 |
"/ is the compressed or stored data for the file. |
|
1260 |
"/ The series of [local file header][file data][data |
|
1261 |
"/ descriptor] repeats for each file in the .ZIP archive. |
|
1262 |
"/ |
|
1263 |
"/ C. Data descriptor: |
|
1264 |
"/ |
|
1265 |
"/ crc-32 4 bytes |
|
1266 |
"/ compressed size 4 bytes |
|
1267 |
"/ uncompressed size 4 bytes |
|
1268 |
"/ |
|
1269 |
"/ This descriptor exists only if bit 3 of the general |
|
1270 |
"/ purpose bit flag is set (see below). It is byte aligned |
|
1271 |
"/ and immediately follows the last byte of compressed data. |
|
1272 |
"/ This descriptor is used only when it was not possible to |
|
1273 |
"/ seek in the output .ZIP file, e.g., when the output .ZIP file |
|
1274 |
"/ was standard output or a non-seekable device. For ZIP64(tm) format |
|
1275 |
"/ archives, the compressed and uncompressed sizes are 8 bytes each. |
|
1276 |
"/ |
|
1277 |
"/ When compressing files, compressed and uncompressed sizes |
|
1278 |
"/ should be stored in ZIP64 format (as 8 byte values) when a |
|
1279 |
"/ files size exceeds 0xFFFFFFFF. However ZIP64 format may be |
|
1280 |
"/ used regardless of the size of a file. When extracting, if |
|
1281 |
"/ the zip64 extended information extra field is present for |
|
1282 |
"/ the file the compressed and uncompressed sizes will be 8 |
|
1283 |
"/ byte values. |
|
1284 |
"/ |
|
1285 |
"/ Although not originally assigned a signature, the value |
|
1286 |
"/ 0x08074b50 has commonly been adopted as a signature value |
|
1287 |
"/ for the data descriptor record. Implementers should be |
|
1288 |
"/ aware that ZIP files may be encountered with or without this |
|
1289 |
"/ signature marking data descriptors and should account for |
|
1290 |
"/ either case when reading ZIP files to ensure compatibility. |
|
1291 |
"/ When writing ZIP files, it is recommended to include the |
|
1292 |
"/ signature value marking the data descriptor record. When |
|
1293 |
"/ the signature is used, the fields currently defined for |
|
1294 |
"/ the data descriptor record will immediately follow the |
|
1295 |
"/ signature. |
|
1296 |
"/ |
|
1297 |
"/ An extensible data descriptor will be released in a future |
|
1298 |
"/ version of this APPNOTE. This new record is intended to |
|
1299 |
"/ resolve conflicts with the use of this record going forward, |
|
1300 |
"/ and to provide better support for streamed file processing. |
|
1301 |
"/ |
|
1302 |
"/ When the Central Directory Encryption method is used, the data |
|
1303 |
"/ descriptor record is not required, but may be used. If present, |
|
1304 |
"/ and bit 3 of the general purpose bit field is set to indicate |
|
1305 |
"/ its presence, the values in fields of the data descriptor |
|
1306 |
"/ record should be set to binary zeros. |
|
1307 |
"/ |
|
1308 |
"/ D. Archive decryption header: |
|
1309 |
"/ |
|
1310 |
"/ The Archive Decryption Header is introduced in version 6.2 |
|
1311 |
"/ of the ZIP format specification. This record exists in support |
|
1312 |
"/ of the Central Directory Encryption Feature implemented as part of |
|
1313 |
"/ the Strong Encryption Specification as described in this document. |
|
1314 |
"/ When the Central Directory Structure is encrypted, this decryption |
|
1315 |
"/ header will precede the encrypted data segment. The encrypted |
|
1316 |
"/ data segment will consist of the Archive extra data record (if |
|
1317 |
"/ present) and the encrypted Central Directory Structure data. |
|
1318 |
"/ The format of this data record is identical to the Decryption |
|
1319 |
"/ header record preceding compressed file data. If the central |
|
1320 |
"/ directory structure is encrypted, the location of the start of |
|
1321 |
"/ this data record is determined using the Start of Central Directory |
|
1322 |
"/ field in the Zip64 End of Central Directory record. Refer to the |
|
1323 |
"/ section on the Strong Encryption Specification for information |
|
1324 |
"/ on the fields used in the Archive Decryption Header record. |
|
1325 |
"/ |
|
1326 |
"/ |
|
1327 |
"/ E. Archive extra data record: |
|
1328 |
"/ |
|
1329 |
"/ archive extra data signature 4 bytes (0x08064b50) |
|
1330 |
"/ extra field length 4 bytes |
|
1331 |
"/ extra field data (variable size) |
|
1332 |
"/ |
|
1333 |
"/ The Archive Extra Data Record is introduced in version 6.2 |
|
1334 |
"/ of the ZIP format specification. This record exists in support |
|
1335 |
"/ of the Central Directory Encryption Feature implemented as part of |
|
1336 |
"/ the Strong Encryption Specification as described in this document. |
|
1337 |
"/ When present, this record immediately precedes the central |
|
1338 |
"/ directory data structure. The size of this data record will be |
|
1339 |
"/ included in the Size of the Central Directory field in the |
|
1340 |
"/ End of Central Directory record. If the central directory structure |
|
1341 |
"/ is compressed, but not encrypted, the location of the start of |
|
1342 |
"/ this data record is determined using the Start of Central Directory |
|
1343 |
"/ field in the Zip64 End of Central Directory record. |
|
1344 |
"/ |
|
1345 |
"/ |
|
1346 |
"/ F. Central directory structure: |
|
1347 |
"/ |
|
1348 |
"/ [file header 1] |
|
1349 |
"/ . |
|
1350 |
"/ . |
|
1351 |
"/ . |
|
1352 |
"/ [file header n] |
|
1353 |
"/ [digital signature] |
|
1354 |
"/ |
|
1355 |
"/ File header: |
|
1356 |
"/ |
|
1357 |
"/ central file header signature 4 bytes (0x02014b50) |
|
1358 |
"/ version made by 2 bytes |
|
1359 |
"/ version needed to extract 2 bytes |
|
1360 |
"/ general purpose bit flag 2 bytes |
|
1361 |
"/ compression method 2 bytes |
|
1362 |
"/ last mod file time 2 bytes |
|
1363 |
"/ last mod file date 2 bytes |
|
1364 |
"/ crc-32 4 bytes |
|
1365 |
"/ compressed size 4 bytes |
|
1366 |
"/ uncompressed size 4 bytes |
|
1367 |
"/ file name length 2 bytes |
|
1368 |
"/ extra field length 2 bytes |
|
1369 |
"/ file comment length 2 bytes |
|
1370 |
"/ disk number start 2 bytes |
|
1371 |
"/ internal file attributes 2 bytes |
|
1372 |
"/ external file attributes 4 bytes |
|
1373 |
"/ relative offset of local header 4 bytes |
|
1374 |
"/ |
|
1375 |
"/ file name (variable size) |
|
1376 |
"/ extra field (variable size) |
|
1377 |
"/ file comment (variable size) |
|
1378 |
"/ |
|
1379 |
"/ Digital signature: |
|
1380 |
"/ |
|
1381 |
"/ header signature 4 bytes (0x05054b50) |
|
1382 |
"/ size of data 2 bytes |
|
1383 |
"/ signature data (variable size) |
|
1384 |
"/ |
|
1385 |
"/ With the introduction of the Central Directory Encryption |
|
1386 |
"/ feature in version 6.2 of this specification, the Central |
|
1387 |
"/ Directory Structure may be stored both compressed and encrypted. |
|
1388 |
"/ Although not required, it is assumed when encrypting the |
|
1389 |
"/ Central Directory Structure, that it will be compressed |
|
1390 |
"/ for greater storage efficiency. Information on the |
|
1391 |
"/ Central Directory Encryption feature can be found in the section |
|
1392 |
"/ describing the Strong Encryption Specification. The Digital |
|
1393 |
"/ Signature record will be neither compressed nor encrypted. |
|
1394 |
"/ |
|
1395 |
"/ G. Zip64 end of central directory record |
|
1396 |
"/ |
|
1397 |
"/ zip64 end of central dir |
|
1398 |
"/ signature 4 bytes (0x06064b50) |
|
1399 |
"/ size of zip64 end of central |
|
1400 |
"/ directory record 8 bytes |
|
1401 |
"/ version made by 2 bytes |
|
1402 |
"/ version needed to extract 2 bytes |
|
1403 |
"/ number of this disk 4 bytes |
|
1404 |
"/ number of the disk with the |
|
1405 |
"/ start of the central directory 4 bytes |
|
1406 |
"/ total number of entries in the |
|
1407 |
"/ central directory on this disk 8 bytes |
|
1408 |
"/ total number of entries in the |
|
1409 |
"/ central directory 8 bytes |
|
1410 |
"/ size of the central directory 8 bytes |
|
1411 |
"/ offset of start of central |
|
1412 |
"/ directory with respect to |
|
1413 |
"/ the starting disk number 8 bytes |
|
1414 |
"/ zip64 extensible data sector (variable size) |
|
1415 |
"/ |
|
1416 |
"/ The value stored into the "size of zip64 end of central |
|
1417 |
"/ directory record" should be the size of the remaining |
|
1418 |
"/ record and should not include the leading 12 bytes. |
|
1419 |
"/ |
|
1420 |
"/ Size = SizeOfFixedFields + SizeOfVariableData - 12. |
|
1421 |
"/ |
|
1422 |
"/ The above record structure defines Version 1 of the |
|
1423 |
"/ zip64 end of central directory record. Version 1 was |
|
1424 |
"/ implemented in versions of this specification preceding |
|
1425 |
"/ 6.2 in support of the ZIP64 large file feature. The |
|
1426 |
"/ introduction of the Central Directory Encryption feature |
|
1427 |
"/ implemented in version 6.2 as part of the Strong Encryption |
|
1428 |
"/ Specification defines Version 2 of this record structure. |
|
1429 |
"/ Refer to the section describing the Strong Encryption |
|
1430 |
"/ Specification for details on the version 2 format for |
|
1431 |
"/ this record. |
|
1432 |
"/ |
|
1433 |
"/ Special purpose data may reside in the zip64 extensible data |
|
1434 |
"/ sector field following either a V1 or V2 version of this |
|
1435 |
"/ record. To ensure identification of this special purpose data |
|
1436 |
"/ it must include an identifying header block consisting of the |
|
1437 |
"/ following: |
|
1438 |
"/ |
|
1439 |
"/ Header ID - 2 bytes |
|
1440 |
"/ Data Size - 4 bytes |
|
1441 |
"/ |
|
1442 |
"/ The Header ID field indicates the type of data that is in the |
|
1443 |
"/ data block that follows. |
|
1444 |
"/ |
|
1445 |
"/ Data Size identifies the number of bytes that follow for this |
|
1446 |
"/ data block type. |
|
1447 |
"/ |
|
1448 |
"/ Multiple special purpose data blocks may be present, but each |
|
1449 |
"/ must be preceded by a Header ID and Data Size field. Current |
|
1450 |
"/ mappings of Header ID values supported in this field are as |
|
1451 |
"/ defined in APPENDIX C. |
|
1452 |
"/ |
|
1453 |
"/ H. Zip64 end of central directory locator |
|
1454 |
"/ |
|
1455 |
"/ zip64 end of central dir locator |
|
1456 |
"/ signature 4 bytes (0x07064b50) |
|
1457 |
"/ number of the disk with the |
|
1458 |
"/ start of the zip64 end of |
|
1459 |
"/ central directory 4 bytes |
|
1460 |
"/ relative offset of the zip64 |
|
1461 |
"/ end of central directory record 8 bytes |
|
1462 |
"/ total number of disks 4 bytes |
|
1463 |
"/ |
|
1464 |
"/ I. End of central directory record: |
|
1465 |
"/ |
|
1466 |
"/ end of central dir signature 4 bytes (0x06054b50) |
|
1467 |
"/ number of this disk 2 bytes |
|
1468 |
"/ number of the disk with the |
|
1469 |
"/ start of the central directory 2 bytes |
|
1470 |
"/ total number of entries in the |
|
1471 |
"/ central directory on this disk 2 bytes |
|
1472 |
"/ total number of entries in |
|
1473 |
"/ the central directory 2 bytes |
|
1474 |
"/ size of the central directory 4 bytes |
|
1475 |
"/ offset of start of central |
|
1476 |
"/ directory with respect to |
|
1477 |
"/ the starting disk number 4 bytes |
|
1478 |
"/ .ZIP file comment length 2 bytes |
|
1479 |
"/ .ZIP file comment (variable size) |
|
1480 |
"/ |
|
1481 |
"/ J. Explanation of fields: |
|
1482 |
"/ |
|
1483 |
"/ version made by (2 bytes) |
|
1484 |
"/ |
|
1485 |
"/ The upper byte indicates the compatibility of the file |
|
1486 |
"/ attribute information. If the external file attributes |
|
1487 |
"/ are compatible with MS-DOS and can be read by PKZIP for |
|
1488 |
"/ DOS version 2.04g then this value will be zero. If these |
|
1489 |
"/ attributes are not compatible, then this value will |
|
1490 |
"/ identify the host system on which the attributes are |
|
1491 |
"/ compatible. Software can use this information to determine |
|
1492 |
"/ the line record format for text files etc. The current |
|
1493 |
"/ mappings are: |
|
1494 |
"/ |
|
1495 |
"/ 0 - MS-DOS and OS/2 (FAT / VFAT / FAT32 file systems) |
|
1496 |
"/ 1 - Amiga 2 - OpenVMS |
|
1497 |
"/ 3 - UNIX 4 - VM/CMS |
|
1498 |
"/ 5 - Atari ST 6 - OS/2 H.P.F.S. |
|
1499 |
"/ 7 - Macintosh 8 - Z-System |
|
1500 |
"/ 9 - CP/M 10 - Windows NTFS |
|
1501 |
"/ 11 - MVS (OS/390 - Z/OS) 12 - VSE |
|
1502 |
"/ 13 - Acorn Risc 14 - VFAT |
|
1503 |
"/ 15 - alternate MVS 16 - BeOS |
|
1504 |
"/ 17 - Tandem 18 - OS/400 |
|
1505 |
"/ 19 - OS/X (Darwin) 20 thru 255 - unused |
|
1506 |
"/ |
|
1507 |
"/ The lower byte indicates the ZIP specification version |
|
1508 |
"/ (the version of this document) supported by the software |
|
1509 |
"/ used to encode the file. The value/10 indicates the major |
|
1510 |
"/ version number, and the value mod 10 is the minor version |
|
1511 |
"/ number. |
|
1512 |
"/ |
|
1513 |
"/ version needed to extract (2 bytes) |
|
1514 |
"/ |
|
1515 |
"/ The minimum supported ZIP specification version needed to |
|
1516 |
"/ extract the file, mapped as above. This value is based on |
|
1517 |
"/ the specific format features a ZIP program must support to |
|
1518 |
"/ be able to extract the file. If multiple features are |
|
1519 |
"/ applied to a file, the minimum version should be set to the |
|
1520 |
"/ feature having the highest value. New features or feature |
|
1521 |
"/ changes affecting the published format specification will be |
|
1522 |
"/ implemented using higher version numbers than the last |
|
1523 |
"/ published value to avoid conflict. |
|
1524 |
"/ |
|
1525 |
"/ Current minimum feature versions are as defined below: |
|
1526 |
"/ |
|
1527 |
"/ 1.0 - Default value |
|
1528 |
"/ 1.1 - File is a volume label |
|
1529 |
"/ 2.0 - File is a folder (directory) |
|
1530 |
"/ 2.0 - File is compressed using Deflate compression |
|
1531 |
"/ 2.0 - File is encrypted using traditional PKWARE encryption |
|
1532 |
"/ 2.1 - File is compressed using Deflate64(tm) |
|
1533 |
"/ 2.5 - File is compressed using PKWARE DCL Implode |
|
1534 |
"/ 2.7 - File is a patch data set |
|
1535 |
"/ 4.5 - File uses ZIP64 format extensions |
|
1536 |
"/ 4.6 - File is compressed using BZIP2 compression* |
|
1537 |
"/ 5.0 - File is encrypted using DES |
|
1538 |
"/ 5.0 - File is encrypted using 3DES |
|
1539 |
"/ 5.0 - File is encrypted using original RC2 encryption |
|
1540 |
"/ 5.0 - File is encrypted using RC4 encryption |
|
1541 |
"/ 5.1 - File is encrypted using AES encryption |
|
1542 |
"/ 5.1 - File is encrypted using corrected RC2 encryption** |
|
1543 |
"/ 5.2 - File is encrypted using corrected RC2-64 encryption** |
|
1544 |
"/ 6.1 - File is encrypted using non-OAEP key wrapping*** |
|
1545 |
"/ 6.2 - Central directory encryption |
|
1546 |
"/ 6.3 - File is compressed using LZMA |
|
1547 |
"/ 6.3 - File is compressed using PPMd+ |
|
1548 |
"/ 6.3 - File is encrypted using Blowfish |
|
1549 |
"/ 6.3 - File is encrypted using Twofish |
|
1550 |
"/ |
|
1551 |
"/ |
|
1552 |
"/ * Early 7.x (pre-7.2) versions of PKZIP incorrectly set the |
|
1553 |
"/ version needed to extract for BZIP2 compression to be 50 |
|
1554 |
"/ when it should have been 46. |
|
1555 |
"/ |
|
1556 |
"/ ** Refer to the section on Strong Encryption Specification |
|
1557 |
"/ for additional information regarding RC2 corrections. |
|
1558 |
"/ |
|
1559 |
"/ *** Certificate encryption using non-OAEP key wrapping is the |
|
1560 |
"/ intended mode of operation for all versions beginning with 6.1. |
|
1561 |
"/ Support for OAEP key wrapping should only be used for |
|
1562 |
"/ backward compatibility when sending ZIP files to be opened by |
|
1563 |
"/ versions of PKZIP older than 6.1 (5.0 or 6.0). |
|
1564 |
"/ |
|
1565 |
"/ + Files compressed using PPMd should set the version |
|
1566 |
"/ needed to extract field to 6.3, however, not all ZIP |
|
1567 |
"/ programs enforce this and may be unable to decompress |
|
1568 |
"/ data files compressed using PPMd if this value is set. |
|
1569 |
"/ |
|
1570 |
"/ When using ZIP64 extensions, the corresponding value in the |
|
1571 |
"/ zip64 end of central directory record should also be set. |
|
1572 |
"/ This field should be set appropriately to indicate whether |
|
1573 |
"/ Version 1 or Version 2 format is in use. |
|
1574 |
"/ |
|
1575 |
"/ general purpose bit flag: (2 bytes) |
|
1576 |
"/ |
|
1577 |
"/ Bit 0: If set, indicates that the file is encrypted. |
|
1578 |
"/ |
|
1579 |
"/ (For Method 6 - Imploding) |
|
1580 |
"/ Bit 1: If the compression method used was type 6, |
|
1581 |
"/ Imploding, then this bit, if set, indicates |
|
1582 |
"/ an 8K sliding dictionary was used. If clear, |
|
1583 |
"/ then a 4K sliding dictionary was used. |
|
1584 |
"/ Bit 2: If the compression method used was type 6, |
|
1585 |
"/ Imploding, then this bit, if set, indicates |
|
1586 |
"/ 3 Shannon-Fano trees were used to encode the |
|
1587 |
"/ sliding dictionary output. If clear, then 2 |
|
1588 |
"/ Shannon-Fano trees were used. |
|
1589 |
"/ |
|
1590 |
"/ (For Methods 8 and 9 - Deflating) |
|
1591 |
"/ Bit 2 Bit 1 |
|
1592 |
"/ 0 0 Normal (-en) compression option was used. |
|
1593 |
"/ 0 1 Maximum (-exx/-ex) compression option was used. |
|
1594 |
"/ 1 0 Fast (-ef) compression option was used. |
|
1595 |
"/ 1 1 Super Fast (-es) compression option was used. |
|
1596 |
"/ |
|
1597 |
"/ (For Method 14 - LZMA) |
|
1598 |
"/ Bit 1: If the compression method used was type 14, |
|
1599 |
"/ LZMA, then this bit, if set, indicates |
|
1600 |
"/ an end-of-stream (EOS) marker is used to |
|
1601 |
"/ mark the end of the compressed data stream. |
|
1602 |
"/ If clear, then an EOS marker is not present |
|
1603 |
"/ and the compressed data size must be known |
|
1604 |
"/ to extract. |
|
1605 |
"/ |
|
1606 |
"/ Note: Bits 1 and 2 are undefined if the compression |
|
1607 |
"/ method is any other. |
|
1608 |
"/ |
|
1609 |
"/ Bit 3: If this bit is set, the fields crc-32, compressed |
|
1610 |
"/ size and uncompressed size are set to zero in the |
|
1611 |
"/ local header. The correct values are put in the |
|
1612 |
"/ data descriptor immediately following the compressed |
|
1613 |
"/ data. (Note: PKZIP version 2.04g for DOS only |
|
1614 |
"/ recognizes this bit for method 8 compression, newer |
|
1615 |
"/ versions of PKZIP recognize this bit for any |
|
1616 |
"/ compression method.) |
|
1617 |
"/ |
|
1618 |
"/ Bit 4: Reserved for use with method 8, for enhanced |
|
1619 |
"/ deflating. |
|
1620 |
"/ |
|
1621 |
"/ Bit 5: If this bit is set, this indicates that the file is |
|
1622 |
"/ compressed patched data. (Note: Requires PKZIP |
|
1623 |
"/ version 2.70 or greater) |
|
1624 |
"/ |
|
1625 |
"/ Bit 6: Strong encryption. If this bit is set, you should |
|
1626 |
"/ set the version needed to extract value to at least |
|
1627 |
"/ 50 and you must also set bit 0. If AES encryption |
|
1628 |
"/ is used, the version needed to extract value must |
|
1629 |
"/ be at least 51. |
|
1630 |
"/ |
|
1631 |
"/ Bit 7: Currently unused. |
|
1632 |
"/ |
|
1633 |
"/ Bit 8: Currently unused. |
|
1634 |
"/ |
|
1635 |
"/ Bit 9: Currently unused. |
|
1636 |
"/ |
|
1637 |
"/ Bit 10: Currently unused. |
|
1638 |
"/ |
|
1639 |
"/ Bit 11: Language encoding flag (EFS). If this bit is set, |
|
1640 |
"/ the filename and comment fields for this file |
|
1641 |
"/ must be encoded using UTF-8. (see APPENDIX D) |
|
1642 |
"/ |
|
1643 |
"/ Bit 12: Reserved by PKWARE for enhanced compression. |
|
1644 |
"/ |
|
1645 |
"/ Bit 13: Used when encrypting the Central Directory to indicate |
|
1646 |
"/ selected data values in the Local Header are masked to |
|
1647 |
"/ hide their actual values. See the section describing |
|
1648 |
"/ the Strong Encryption Specification for details. |
|
1649 |
"/ |
|
1650 |
"/ Bit 14: Reserved by PKWARE. |
|
1651 |
"/ |
|
1652 |
"/ Bit 15: Reserved by PKWARE. |
|
1653 |
"/ |
|
1654 |
"/ compression method: (2 bytes) |
|
1655 |
"/ |
|
1656 |
"/ (see accompanying documentation for algorithm |
|
1657 |
"/ descriptions) |
|
1658 |
"/ |
|
1659 |
"/ 0 - The file is stored (no compression) |
|
1660 |
"/ 1 - The file is Shrunk |
|
1661 |
"/ 2 - The file is Reduced with compression factor 1 |
|
1662 |
"/ 3 - The file is Reduced with compression factor 2 |
|
1663 |
"/ 4 - The file is Reduced with compression factor 3 |
|
1664 |
"/ 5 - The file is Reduced with compression factor 4 |
|
1665 |
"/ 6 - The file is Imploded |
|
1666 |
"/ 7 - Reserved for Tokenizing compression algorithm |
|
1667 |
"/ 8 - The file is Deflated |
|
1668 |
"/ 9 - Enhanced Deflating using Deflate64(tm) |
|
1669 |
"/ 10 - PKWARE Data Compression Library Imploding (old IBM TERSE) |
|
1670 |
"/ 11 - Reserved by PKWARE |
|
1671 |
"/ 12 - File is compressed using BZIP2 algorithm |
|
1672 |
"/ 13 - Reserved by PKWARE |
|
1673 |
"/ 14 - LZMA (EFS) |
|
1674 |
"/ 15 - Reserved by PKWARE |
|
1675 |
"/ 16 - Reserved by PKWARE |
|
1676 |
"/ 17 - Reserved by PKWARE |
|
1677 |
"/ 18 - File is compressed using IBM TERSE (new) |
|
1678 |
"/ 19 - IBM LZ77 z Architecture (PFS) |
|
1679 |
"/ 97 - WavPack compressed data |
|
1680 |
"/ 98 - PPMd version I, Rev 1 |
|
1681 |
"/ |
|
1682 |
"/ date and time fields: (2 bytes each) |
|
1683 |
"/ |
|
1684 |
"/ The date and time are encoded in standard MS-DOS format. |
|
1685 |
"/ If input came from standard input, the date and time are |
|
1686 |
"/ those at which compression was started for this data. |
|
1687 |
"/ If encrypting the central directory and general purpose bit |
|
1688 |
"/ flag 13 is set indicating masking, the value stored in the |
|
1689 |
"/ Local Header will be zero. |
|
1690 |
"/ |
|
1691 |
"/ CRC-32: (4 bytes) |
|
1692 |
"/ |
|
1693 |
"/ The CRC-32 algorithm was generously contributed by |
|
1694 |
"/ David Schwaderer and can be found in his excellent |
|
1695 |
"/ book "C Programmers Guide to NetBIOS" published by |
|
1696 |
"/ Howard W. Sams & Co. Inc. The 'magic number' for |
|
1697 |
"/ the CRC is 0xdebb20e3. The proper CRC pre and post |
|
1698 |
"/ conditioning is used, meaning that the CRC register |
|
1699 |
"/ is pre-conditioned with all ones (a starting value |
|
1700 |
"/ of 0xffffffff) and the value is post-conditioned by |
|
1701 |
"/ taking the one's complement of the CRC residual. |
|
1702 |
"/ If bit 3 of the general purpose flag is set, this |
|
1703 |
"/ field is set to zero in the local header and the correct |
|
1704 |
"/ value is put in the data descriptor and in the central |
|
1705 |
"/ directory. When encrypting the central directory, if the |
|
1706 |
"/ local header is not in ZIP64 format and general purpose |
|
1707 |
"/ bit flag 13 is set indicating masking, the value stored |
|
1708 |
"/ in the Local Header will be zero. |
|
1709 |
"/ |
|
1710 |
"/ compressed size: (4 bytes) |
|
1711 |
"/ uncompressed size: (4 bytes) |
|
1712 |
"/ |
|
1713 |
"/ The size of the file compressed and uncompressed, |
|
1714 |
"/ respectively. When a decryption header is present it will |
|
1715 |
"/ be placed in front of the file data and the value of the |
|
1716 |
"/ compressed file size will include the bytes of the decryption |
|
1717 |
"/ header. If bit 3 of the general purpose bit flag is set, |
|
1718 |
"/ these fields are set to zero in the local header and the |
|
1719 |
"/ correct values are put in the data descriptor and |
|
1720 |
"/ in the central directory. If an archive is in ZIP64 format |
|
1721 |
"/ and the value in this field is 0xFFFFFFFF, the size will be |
|
1722 |
"/ in the corresponding 8 byte ZIP64 extended information |
|
1723 |
"/ extra field. When encrypting the central directory, if the |
|
1724 |
"/ local header is not in ZIP64 format and general purpose bit |
|
1725 |
"/ flag 13 is set indicating masking, the value stored for the |
|
1726 |
"/ uncompressed size in the Local Header will be zero. |
|
1727 |
"/ |
|
1728 |
"/ file name length: (2 bytes) |
|
1729 |
"/ extra field length: (2 bytes) |
|
1730 |
"/ file comment length: (2 bytes) |
|
1731 |
"/ |
|
1732 |
"/ The length of the file name, extra field, and comment |
|
1733 |
"/ fields respectively. The combined length of any |
|
1734 |
"/ directory record and these three fields should not |
|
1735 |
"/ generally exceed 65,535 bytes. If input came from standard |
|
1736 |
"/ input, the file name length is set to zero. |
|
1737 |
"/ |
|
1738 |
"/ disk number start: (2 bytes) |
|
1739 |
"/ |
|
1740 |
"/ The number of the disk on which this file begins. If an |
|
1741 |
"/ archive is in ZIP64 format and the value in this field is |
|
1742 |
"/ 0xFFFF, the size will be in the corresponding 4 byte zip64 |
|
1743 |
"/ extended information extra field. |
|
1744 |
"/ |
|
1745 |
"/ internal file attributes: (2 bytes) |
|
1746 |
"/ |
|
1747 |
"/ Bits 1 and 2 are reserved for use by PKWARE. |
|
1748 |
"/ |
|
1749 |
"/ The lowest bit of this field indicates, if set, that |
|
1750 |
"/ the file is apparently an ASCII or text file. If not |
|
1751 |
"/ set, that the file apparently contains binary data. |
|
1752 |
"/ The remaining bits are unused in version 1.0. |
|
1753 |
"/ |
|
1754 |
"/ The 0x0002 bit of this field indicates, if set, that a |
|
1755 |
"/ 4 byte variable record length control field precedes each |
|
1756 |
"/ logical record indicating the length of the record. The |
|
1757 |
"/ record length control field is stored in little-endian byte |
|
1758 |
"/ order. This flag is independent of text control characters, |
|
1759 |
"/ and if used in conjunction with text data, includes any |
|
1760 |
"/ control characters in the total length of the record. This |
|
1761 |
"/ value is provided for mainframe data transfer support. |
|
1762 |
"/ |
|
1763 |
"/ external file attributes: (4 bytes) |
|
1764 |
"/ |
|
1765 |
"/ The mapping of the external attributes is |
|
1766 |
"/ host-system dependent (see 'version made by'). For |
|
1767 |
"/ MS-DOS, the low order byte is the MS-DOS directory |
|
1768 |
"/ attribute byte. If input came from standard input, this |
|
1769 |
"/ field is set to zero. |
|
1770 |
"/ |
|
1771 |
"/ relative offset of local header: (4 bytes) |
|
1772 |
"/ |
|
1773 |
"/ This is the offset from the start of the first disk on |
|
1774 |
"/ which this file appears, to where the local header should |
|
1775 |
"/ be found. If an archive is in ZIP64 format and the value |
|
1776 |
"/ in this field is 0xFFFFFFFF, the size will be in the |
|
1777 |
"/ corresponding 8 byte zip64 extended information extra field. |
|
1778 |
"/ |
|
1779 |
"/ file name: (Variable) |
|
1780 |
"/ |
|
1781 |
"/ The name of the file, with optional relative path. |
|
1782 |
"/ The path stored should not contain a drive or |
|
1783 |
"/ device letter, or a leading slash. All slashes |
|
1784 |
"/ should be forward slashes '/' as opposed to |
|
1785 |
"/ backwards slashes '\' for compatibility with Amiga |
|
1786 |
"/ and UNIX file systems etc. If input came from standard |
|
1787 |
"/ input, there is no file name field. If encrypting |
|
1788 |
"/ the central directory and general purpose bit flag 13 is set |
|
1789 |
"/ indicating masking, the file name stored in the Local Header |
|
1790 |
"/ will not be the actual file name. A masking value consisting |
|
1791 |
"/ of a unique hexadecimal value will be stored. This value will |
|
1792 |
"/ be sequentially incremented for each file in the archive. See |
|
1793 |
"/ the section on the Strong Encryption Specification for details |
|
1794 |
"/ on retrieving the encrypted file name. |
|
1795 |
"/ |
|
1796 |
"/ extra field: (Variable) |
|
1797 |
"/ |
|
1798 |
"/ This is for expansion. If additional information |
|
1799 |
"/ needs to be stored for special needs or for specific |
|
1800 |
"/ platforms, it should be stored here. Earlier versions |
|
1801 |
"/ of the software can then safely skip this file, and |
|
1802 |
"/ find the next file or header. This field will be 0 |
|
1803 |
"/ length in version 1.0. |
|
1804 |
"/ |
|
1805 |
"/ In order to allow different programs and different types |
|
1806 |
"/ of information to be stored in the 'extra' field in .ZIP |
|
1807 |
"/ files, the following structure should be used for all |
|
1808 |
"/ programs storing data in this field: |
|
1809 |
"/ |
|
1810 |
"/ header1+data1 + header2+data2 . . . |
|
1811 |
"/ |
|
1812 |
"/ Each header should consist of: |
|
1813 |
"/ |
|
1814 |
"/ Header ID - 2 bytes |
|
1815 |
"/ Data Size - 2 bytes |
|
1816 |
"/ |
|
1817 |
"/ Note: all fields stored in Intel low-byte/high-byte order. |
|
1818 |
"/ |
|
1819 |
"/ The Header ID field indicates the type of data that is in |
|
1820 |
"/ the following data block. |
|
1821 |
"/ |
|
1822 |
"/ Header ID's of 0 thru 31 are reserved for use by PKWARE. |
|
1823 |
"/ The remaining ID's can be used by third party vendors for |
|
1824 |
"/ proprietary usage. |
|
1825 |
"/ |
|
1826 |
"/ The current Header ID mappings defined by PKWARE are: |
|
1827 |
"/ |
|
1828 |
"/ 0x0001 Zip64 extended information extra field |
|
1829 |
"/ 0x0007 AV Info |
|
1830 |
"/ 0x0008 Reserved for extended language encoding data (PFS) |
|
1831 |
"/ (see APPENDIX D) |
|
1832 |
"/ 0x0009 OS/2 |
|
1833 |
"/ 0x000a NTFS |
|
1834 |
"/ 0x000c OpenVMS |
|
1835 |
"/ 0x000d UNIX |
|
1836 |
"/ 0x000e Reserved for file stream and fork descriptors |
|
1837 |
"/ 0x000f Patch Descriptor |
|
1838 |
"/ 0x0014 PKCS#7 Store for X.509 Certificates |
|
1839 |
"/ 0x0015 X.509 Certificate ID and Signature for |
|
1840 |
"/ individual file |
|
1841 |
"/ 0x0016 X.509 Certificate ID for Central Directory |
|
1842 |
"/ 0x0017 Strong Encryption Header |
|
1843 |
"/ 0x0018 Record Management Controls |
|
1844 |
"/ 0x0019 PKCS#7 Encryption Recipient Certificate List |
|
1845 |
"/ 0x0065 IBM S/390 (Z390), AS/400 (I400) attributes |
|
1846 |
"/ - uncompressed |
|
1847 |
"/ 0x0066 Reserved for IBM S/390 (Z390), AS/400 (I400) |
|
1848 |
"/ attributes - compressed |
|
1849 |
"/ 0x4690 POSZIP 4690 (reserved) |
|
1850 |
"/ |
|
1851 |
"/ Third party mappings commonly used are: |
|
1852 |
"/ |
|
1853 |
"/ |
|
1854 |
"/ 0x07c8 Macintosh |
|
1855 |
"/ 0x2605 ZipIt Macintosh |
|
1856 |
"/ 0x2705 ZipIt Macintosh 1.3.5+ |
|
1857 |
"/ 0x2805 ZipIt Macintosh 1.3.5+ |
|
1858 |
"/ 0x334d Info-ZIP Macintosh |
|
1859 |
"/ 0x4341 Acorn/SparkFS |
|
1860 |
"/ 0x4453 Windows NT security descriptor (binary ACL) |
|
1861 |
"/ 0x4704 VM/CMS |
|
1862 |
"/ 0x470f MVS |
|
1863 |
"/ 0x4b46 FWKCS MD5 (see below) |
|
1864 |
"/ 0x4c41 OS/2 access control list (text ACL) |
|
1865 |
"/ 0x4d49 Info-ZIP OpenVMS |
|
1866 |
"/ 0x4f4c Xceed original location extra field |
|
1867 |
"/ 0x5356 AOS/VS (ACL) |
|
1868 |
"/ 0x5455 extended timestamp |
|
1869 |
"/ 0x554e Xceed unicode extra field |
|
1870 |
"/ 0x5855 Info-ZIP UNIX (original, also OS/2, NT, etc) |
|
1871 |
"/ 0x6375 Info-ZIP Unicode Comment Extra Field |
|
1872 |
"/ 0x6542 BeOS/BeBox |
|
1873 |
"/ 0x7075 Info-ZIP Unicode Path Extra Field |
|
1874 |
"/ 0x756e ASi UNIX |
|
1875 |
"/ 0x7855 Info-ZIP UNIX (new) |
|
1876 |
"/ 0xa220 Microsoft Open Packaging Growth Hint |
|
1877 |
"/ 0xfd4a SMS/QDOS |
|
1878 |
"/ |
|
1879 |
"/ Detailed descriptions of Extra Fields defined by third |
|
1880 |
"/ party mappings will be documented as information on |
|
1881 |
"/ these data structures is made available to PKWARE. |
|
1882 |
"/ PKWARE does not guarantee the accuracy of any published |
|
1883 |
"/ third party data. |
|
1884 |
"/ |
|
1885 |
"/ The Data Size field indicates the size of the following |
|
1886 |
"/ data block. Programs can use this value to skip to the |
|
1887 |
"/ next header block, passing over any data blocks that are |
|
1888 |
"/ not of interest. |
|
1889 |
"/ |
|
1890 |
"/ Note: As stated above, the size of the entire .ZIP file |
|
1891 |
"/ header, including the file name, comment, and extra |
|
1892 |
"/ field should not exceed 64K in size. |
|
1893 |
"/ |
|
1894 |
"/ In case two different programs should appropriate the same |
|
1895 |
"/ Header ID value, it is strongly recommended that each |
|
1896 |
"/ program place a unique signature of at least two bytes in |
|
1897 |
"/ size (and preferably 4 bytes or bigger) at the start of |
|
1898 |
"/ each data area. Every program should verify that its |
|
1899 |
"/ unique signature is present, in addition to the Header ID |
|
1900 |
"/ value being correct, before assuming that it is a block of |
|
1901 |
"/ known type. |
|
1902 |
"/ |
|
1903 |
"/ -Zip64 Extended Information Extra Field (0x0001): |
|
1904 |
"/ |
|
1905 |
"/ The following is the layout of the zip64 extended |
|
1906 |
"/ information "extra" block. If one of the size or |
|
1907 |
"/ offset fields in the Local or Central directory |
|
1908 |
"/ record is too small to hold the required data, |
|
1909 |
"/ a Zip64 extended information record is created. |
|
1910 |
"/ The order of the fields in the zip64 extended |
|
1911 |
"/ information record is fixed, but the fields will |
|
1912 |
"/ only appear if the corresponding Local or Central |
|
1913 |
"/ directory record field is set to 0xFFFF or 0xFFFFFFFF. |
|
1914 |
"/ |
|
1915 |
"/ Note: all fields stored in Intel low-byte/high-byte order. |
|
1916 |
"/ |
|
1917 |
"/ Value Size Description |
|
1918 |
"/ ----- ---- ----------- |
|
1919 |
"/ (ZIP64) 0x0001 2 bytes Tag for this "extra" block type |
|
1920 |
"/ Size 2 bytes Size of this "extra" block |
|
1921 |
"/ Original |
|
1922 |
"/ Size 8 bytes Original uncompressed file size |
|
1923 |
"/ Compressed |
|
1924 |
"/ Size 8 bytes Size of compressed data |
|
1925 |
"/ Relative Header |
|
1926 |
"/ Offset 8 bytes Offset of local header record |
|
1927 |
"/ Disk Start |
|
1928 |
"/ Number 4 bytes Number of the disk on which |
|
1929 |
"/ this file starts |
|
1930 |
"/ |
|
1931 |
"/ This entry in the Local header must include BOTH original |
|
1932 |
"/ and compressed file size fields. If encrypting the |
|
1933 |
"/ central directory and bit 13 of the general purpose bit |
|
1934 |
"/ flag is set indicating masking, the value stored in the |
|
1935 |
"/ Local Header for the original file size will be zero. |
|
1936 |
"/ |
|
1937 |
"/ |
|
1938 |
"/ -OS/2 Extra Field (0x0009): |
|
1939 |
"/ |
|
1940 |
"/ The following is the layout of the OS/2 attributes "extra" |
|
1941 |
"/ block. (Last Revision 09/05/95) |
|
1942 |
"/ |
|
1943 |
"/ Note: all fields stored in Intel low-byte/high-byte order. |
|
1944 |
"/ |
|
1945 |
"/ Value Size Description |
|
1946 |
"/ ----- ---- ----------- |
|
1947 |
"/ (OS/2) 0x0009 2 bytes Tag for this "extra" block type |
|
1948 |
"/ TSize 2 bytes Size for the following data block |
|
1949 |
"/ BSize 4 bytes Uncompressed Block Size |
|
1950 |
"/ CType 2 bytes Compression type |
|
1951 |
"/ EACRC 4 bytes CRC value for uncompress block |
|
1952 |
"/ (var) variable Compressed block |
|
1953 |
"/ |
|
1954 |
"/ The OS/2 extended attribute structure (FEA2LIST) is |
|
1955 |
"/ compressed and then stored in it's entirety within this |
|
1956 |
"/ structure. There will only ever be one "block" of data in |
|
1957 |
"/ VarFields[]. |
|
1958 |
"/ |
|
1959 |
"/ -NTFS Extra Field (0x000a): |
|
1960 |
"/ |
|
1961 |
"/ The following is the layout of the NTFS attributes |
|
1962 |
"/ "extra" block. (Note: At this time the Mtime, Atime |
|
1963 |
"/ and Ctime values may be used on any WIN32 system.) |
|
1964 |
"/ |
|
1965 |
"/ Note: all fields stored in Intel low-byte/high-byte order. |
|
1966 |
"/ |
|
1967 |
"/ Value Size Description |
|
1968 |
"/ ----- ---- ----------- |
|
1969 |
"/ (NTFS) 0x000a 2 bytes Tag for this "extra" block type |
|
1970 |
"/ TSize 2 bytes Size of the total "extra" block |
|
1971 |
"/ Reserved 4 bytes Reserved for future use |
|
1972 |
"/ Tag1 2 bytes NTFS attribute tag value #1 |
|
1973 |
"/ Size1 2 bytes Size of attribute #1, in bytes |
|
1974 |
"/ (var.) Size1 Attribute #1 data |
|
1975 |
"/ . |
|
1976 |
"/ . |
|
1977 |
"/ . |
|
1978 |
"/ TagN 2 bytes NTFS attribute tag value #N |
|
1979 |
"/ SizeN 2 bytes Size of attribute #N, in bytes |
|
1980 |
"/ (var.) SizeN Attribute #N data |
|
1981 |
"/ |
|
1982 |
"/ For NTFS, values for Tag1 through TagN are as follows: |
|
1983 |
"/ (currently only one set of attributes is defined for NTFS) |
|
1984 |
"/ |
|
1985 |
"/ Tag Size Description |
|
1986 |
"/ ----- ---- ----------- |
|
1987 |
"/ 0x0001 2 bytes Tag for attribute #1 |
|
1988 |
"/ Size1 2 bytes Size of attribute #1, in bytes |
|
1989 |
"/ Mtime 8 bytes File last modification time |
|
1990 |
"/ Atime 8 bytes File last access time |
|
1991 |
"/ Ctime 8 bytes File creation time |
|
1992 |
"/ |
|
1993 |
"/ -OpenVMS Extra Field (0x000c): |
|
1994 |
"/ |
|
1995 |
"/ The following is the layout of the OpenVMS attributes |
|
1996 |
"/ "extra" block. |
|
1997 |
"/ |
|
1998 |
"/ Note: all fields stored in Intel low-byte/high-byte order. |
|
1999 |
"/ |
|
2000 |
"/ Value Size Description |
|
2001 |
"/ ----- ---- ----------- |
|
2002 |
"/ (VMS) 0x000c 2 bytes Tag for this "extra" block type |
|
2003 |
"/ TSize 2 bytes Size of the total "extra" block |
|
2004 |
"/ CRC 4 bytes 32-bit CRC for remainder of the block |
|
2005 |
"/ Tag1 2 bytes OpenVMS attribute tag value #1 |
|
2006 |
"/ Size1 2 bytes Size of attribute #1, in bytes |
|
2007 |
"/ (var.) Size1 Attribute #1 data |
|
2008 |
"/ . |
|
2009 |
"/ . |
|
2010 |
"/ . |
|
2011 |
"/ TagN 2 bytes OpenVMS attribute tag value #N |
|
2012 |
"/ SizeN 2 bytes Size of attribute #N, in bytes |
|
2013 |
"/ (var.) SizeN Attribute #N data |
|
2014 |
"/ |
|
2015 |
"/ Rules: |
|
2016 |
"/ |
|
2017 |
"/ 1. There will be one or more of attributes present, which |
|
2018 |
"/ will each be preceded by the above TagX & SizeX values. |
|
2019 |
"/ These values are identical to the ATR$C_XXXX and |
|
2020 |
"/ ATR$S_XXXX constants which are defined in ATR.H under |
|
2021 |
"/ OpenVMS C. Neither of these values will ever be zero. |
|
2022 |
"/ |
|
2023 |
"/ 2. No word alignment or padding is performed. |
|
2024 |
"/ |
|
2025 |
"/ 3. A well-behaved PKZIP/OpenVMS program should never produce |
|
2026 |
"/ more than one sub-block with the same TagX value. Also, |
|
2027 |
"/ there will never be more than one "extra" block of type |
|
2028 |
"/ 0x000c in a particular directory record. |
|
2029 |
"/ |
|
2030 |
"/ -UNIX Extra Field (0x000d): |
|
2031 |
"/ |
|
2032 |
"/ The following is the layout of the UNIX "extra" block. |
|
2033 |
"/ Note: all fields are stored in Intel low-byte/high-byte |
|
2034 |
"/ order. |
|
2035 |
"/ |
|
2036 |
"/ Value Size Description |
|
2037 |
"/ ----- ---- ----------- |
|
2038 |
"/ (UNIX) 0x000d 2 bytes Tag for this "extra" block type |
|
2039 |
"/ TSize 2 bytes Size for the following data block |
|
2040 |
"/ Atime 4 bytes File last access time |
|
2041 |
"/ Mtime 4 bytes File last modification time |
|
2042 |
"/ Uid 2 bytes File user ID |
|
2043 |
"/ Gid 2 bytes File group ID |
|
2044 |
"/ (var) variable Variable length data field |
|
2045 |
"/ |
|
2046 |
"/ The variable length data field will contain file type |
|
2047 |
"/ specific data. Currently the only values allowed are |
|
2048 |
"/ the original "linked to" file names for hard or symbolic |
|
2049 |
"/ links, and the major and minor device node numbers for |
|
2050 |
"/ character and block device nodes. Since device nodes |
|
2051 |
"/ cannot be either symbolic or hard links, only one set of |
|
2052 |
"/ variable length data is stored. Link files will have the |
|
2053 |
"/ name of the original file stored. This name is NOT NULL |
|
2054 |
"/ terminated. Its size can be determined by checking TSize - |
|
2055 |
"/ 12. Device entries will have eight bytes stored as two 4 |
|
2056 |
"/ byte entries (in little endian format). The first entry |
|
2057 |
"/ will be the major device number, and the second the minor |
|
2058 |
"/ device number. |
|
2059 |
"/ |
|
2060 |
"/ -PATCH Descriptor Extra Field (0x000f): |
|
2061 |
"/ |
|
2062 |
"/ The following is the layout of the Patch Descriptor "extra" |
|
2063 |
"/ block. |
|
2064 |
"/ |
|
2065 |
"/ Note: all fields stored in Intel low-byte/high-byte order. |
|
2066 |
"/ |
|
2067 |
"/ Value Size Description |
|
2068 |
"/ ----- ---- ----------- |
|
2069 |
"/ (Patch) 0x000f 2 bytes Tag for this "extra" block type |
|
2070 |
"/ TSize 2 bytes Size of the total "extra" block |
|
2071 |
"/ Version 2 bytes Version of the descriptor |
|
2072 |
"/ Flags 4 bytes Actions and reactions (see below) |
|
2073 |
"/ OldSize 4 bytes Size of the file about to be patched |
|
2074 |
"/ OldCRC 4 bytes 32-bit CRC of the file to be patched |
|
2075 |
"/ NewSize 4 bytes Size of the resulting file |
|
2076 |
"/ NewCRC 4 bytes 32-bit CRC of the resulting file |
|
2077 |
"/ |
|
2078 |
"/ Actions and reactions |
|
2079 |
"/ |
|
2080 |
"/ Bits Description |
|
2081 |
"/ ---- ---------------- |
|
2082 |
"/ 0 Use for auto detection |
|
2083 |
"/ 1 Treat as a self-patch |
|
2084 |
"/ 2-3 RESERVED |
|
2085 |
"/ 4-5 Action (see below) |
|
2086 |
"/ 6-7 RESERVED |
|
2087 |
"/ 8-9 Reaction (see below) to absent file |
|
2088 |
"/ 10-11 Reaction (see below) to newer file |
|
2089 |
"/ 12-13 Reaction (see below) to unknown file |
|
2090 |
"/ 14-15 RESERVED |
|
2091 |
"/ 16-31 RESERVED |
|
2092 |
"/ |
|
2093 |
"/ Actions |
|
2094 |
"/ |
|
2095 |
"/ Action Value |
|
2096 |
"/ ------ ----- |
|
2097 |
"/ none 0 |
|
2098 |
"/ add 1 |
|
2099 |
"/ delete 2 |
|
2100 |
"/ patch 3 |
|
2101 |
"/ |
|
2102 |
"/ Reactions |
|
2103 |
"/ |
|
2104 |
"/ Reaction Value |
|
2105 |
"/ -------- ----- |
|
2106 |
"/ ask 0 |
|
2107 |
"/ skip 1 |
|
2108 |
"/ ignore 2 |
|
2109 |
"/ fail 3 |
|
2110 |
"/ |
|
2111 |
"/ Patch support is provided by PKPatchMaker(tm) technology and is |
|
2112 |
"/ covered under U.S. Patents and Patents Pending. The use or |
|
2113 |
"/ implementation in a product of certain technological aspects set |
|
2114 |
"/ forth in the current APPNOTE, including those with regard to |
|
2115 |
"/ strong encryption, patching, or extended tape operations requires |
|
2116 |
"/ a license from PKWARE. Please contact PKWARE with regard to |
|
2117 |
"/ acquiring a license. |
|
2118 |
"/ |
|
2119 |
"/ -PKCS#7 Store for X.509 Certificates (0x0014): |
|
2120 |
"/ |
|
2121 |
"/ This field contains information about each of the certificates |
|
2122 |
"/ files may be signed with. When the Central Directory Encryption |
|
2123 |
"/ feature is enabled for a ZIP file, this record will appear in |
|
2124 |
"/ the Archive Extra Data Record, otherwise it will appear in the |
|
2125 |
"/ first central directory record and will be ignored in any |
|
2126 |
"/ other record. |
|
2127 |
"/ |
|
2128 |
"/ Note: all fields stored in Intel low-byte/high-byte order. |
|
2129 |
"/ |
|
2130 |
"/ Value Size Description |
|
2131 |
"/ ----- ---- ----------- |
|
2132 |
"/ (Store) 0x0014 2 bytes Tag for this "extra" block type |
|
2133 |
"/ TSize 2 bytes Size of the store data |
|
2134 |
"/ TData TSize Data about the store |
|
2135 |
"/ |
|
2136 |
"/ |
|
2137 |
"/ -X.509 Certificate ID and Signature for individual file (0x0015): |
|
2138 |
"/ |
|
2139 |
"/ This field contains the information about which certificate in |
|
2140 |
"/ the PKCS#7 store was used to sign a particular file. It also |
|
2141 |
"/ contains the signature data. This field can appear multiple |
|
2142 |
"/ times, but can only appear once per certificate. |
|
2143 |
"/ |
|
2144 |
"/ Note: all fields stored in Intel low-byte/high-byte order. |
|
2145 |
"/ |
|
2146 |
"/ Value Size Description |
|
2147 |
"/ ----- ---- ----------- |
|
2148 |
"/ (CID) 0x0015 2 bytes Tag for this "extra" block type |
|
2149 |
"/ TSize 2 bytes Size of data that follows |
|
2150 |
"/ TData TSize Signature Data |
|
2151 |
"/ |
|
2152 |
"/ -X.509 Certificate ID and Signature for central directory (0x0016): |
|
2153 |
"/ |
|
2154 |
"/ This field contains the information about which certificate in |
|
2155 |
"/ the PKCS#7 store was used to sign the central directory structure. |
|
2156 |
"/ When the Central Directory Encryption feature is enabled for a |
|
2157 |
"/ ZIP file, this record will appear in the Archive Extra Data Record, |
|
2158 |
"/ otherwise it will appear in the first central directory record. |
|
2159 |
"/ |
|
2160 |
"/ Note: all fields stored in Intel low-byte/high-byte order. |
|
2161 |
"/ |
|
2162 |
"/ Value Size Description |
|
2163 |
"/ ----- ---- ----------- |
|
2164 |
"/ (CDID) 0x0016 2 bytes Tag for this "extra" block type |
|
2165 |
"/ TSize 2 bytes Size of data that follows |
|
2166 |
"/ TData TSize Data |
|
2167 |
"/ |
|
2168 |
"/ -Strong Encryption Header (0x0017): |
|
2169 |
"/ |
|
2170 |
"/ Value Size Description |
|
2171 |
"/ ----- ---- ----------- |
|
2172 |
"/ 0x0017 2 bytes Tag for this "extra" block type |
|
2173 |
"/ TSize 2 bytes Size of data that follows |
|
2174 |
"/ Format 2 bytes Format definition for this record |
|
2175 |
"/ AlgID 2 bytes Encryption algorithm identifier |
|
2176 |
"/ Bitlen 2 bytes Bit length of encryption key |
|
2177 |
"/ Flags 2 bytes Processing flags |
|
2178 |
"/ CertData TSize-8 Certificate decryption extra field data |
|
2179 |
"/ (refer to the explanation for CertData |
|
2180 |
"/ in the section describing the |
|
2181 |
"/ Certificate Processing Method under |
|
2182 |
"/ the Strong Encryption Specification) |
|
2183 |
"/ |
|
2184 |
"/ |
|
2185 |
"/ -Record Management Controls (0x0018): |
|
2186 |
"/ |
|
2187 |
"/ Value Size Description |
|
2188 |
"/ ----- ---- ----------- |
|
2189 |
"/(Rec-CTL) 0x0018 2 bytes Tag for this "extra" block type |
|
2190 |
"/ CSize 2 bytes Size of total extra block data |
|
2191 |
"/ Tag1 2 bytes Record control attribute 1 |
|
2192 |
"/ Size1 2 bytes Size of attribute 1, in bytes |
|
2193 |
"/ Data1 Size1 Attribute 1 data |
|
2194 |
"/ . |
|
2195 |
"/ . |
|
2196 |
"/ . |
|
2197 |
"/ TagN 2 bytes Record control attribute N |
|
2198 |
"/ SizeN 2 bytes Size of attribute N, in bytes |
|
2199 |
"/ DataN SizeN Attribute N data |
|
2200 |
"/ |
|
2201 |
"/ |
|
2202 |
"/ -PKCS#7 Encryption Recipient Certificate List (0x0019): |
|
2203 |
"/ |
|
2204 |
"/ This field contains information about each of the certificates |
|
2205 |
"/ used in encryption processing and it can be used to identify who is |
|
2206 |
"/ allowed to decrypt encrypted files. This field should only appear |
|
2207 |
"/ in the archive extra data record. This field is not required and |
|
2208 |
"/ serves only to aide archive modifications by preserving public |
|
2209 |
"/ encryption key data. Individual security requirements may dictate |
|
2210 |
"/ that this data be omitted to deter information exposure. |
|
2211 |
"/ |
|
2212 |
"/ Note: all fields stored in Intel low-byte/high-byte order. |
|
2213 |
"/ |
|
2214 |
"/ Value Size Description |
|
2215 |
"/ ----- ---- ----------- |
|
2216 |
"/ (CStore) 0x0019 2 bytes Tag for this "extra" block type |
|
2217 |
"/ TSize 2 bytes Size of the store data |
|
2218 |
"/ TData TSize Data about the store |
|
2219 |
"/ |
|
2220 |
"/ TData: |
|
2221 |
"/ |
|
2222 |
"/ Value Size Description |
|
2223 |
"/ ----- ---- ----------- |
|
2224 |
"/ Version 2 bytes Format version number - must 0x0001 at this time |
|
2225 |
"/ CStore (var) PKCS#7 data blob |
|
2226 |
"/ |
|
2227 |
"/ |
|
2228 |
"/ -MVS Extra Field (0x0065): |
|
2229 |
"/ |
|
2230 |
"/ The following is the layout of the MVS "extra" block. |
|
2231 |
"/ Note: Some fields are stored in Big Endian format. |
|
2232 |
"/ All text is in EBCDIC format unless otherwise specified. |
|
2233 |
"/ |
|
2234 |
"/ Value Size Description |
|
2235 |
"/ ----- ---- ----------- |
|
2236 |
"/ (MVS) 0x0065 2 bytes Tag for this "extra" block type |
|
2237 |
"/ TSize 2 bytes Size for the following data block |
|
2238 |
"/ ID 4 bytes EBCDIC "Z390" 0xE9F3F9F0 or |
|
2239 |
"/ "T4MV" for TargetFour |
|
2240 |
"/ (var) TSize-4 Attribute data (see APPENDIX B) |
|
2241 |
"/ |
|
2242 |
"/ |
|
2243 |
"/ -OS/400 Extra Field (0x0065): |
|
2244 |
"/ |
|
2245 |
"/ The following is the layout of the OS/400 "extra" block. |
|
2246 |
"/ Note: Some fields are stored in Big Endian format. |
|
2247 |
"/ All text is in EBCDIC format unless otherwise specified. |
|
2248 |
"/ |
|
2249 |
"/ Value Size Description |
|
2250 |
"/ ----- ---- ----------- |
|
2251 |
"/ (OS400) 0x0065 2 bytes Tag for this "extra" block type |
|
2252 |
"/ TSize 2 bytes Size for the following data block |
|
2253 |
"/ ID 4 bytes EBCDIC "I400" 0xC9F4F0F0 or |
|
2254 |
"/ "T4MV" for TargetFour |
|
2255 |
"/ (var) TSize-4 Attribute data (see APPENDIX A) |
|
2256 |
"/ |
|
2257 |
"/ |
|
2258 |
"/ Third-party Mappings: |
|
2259 |
"/ |
|
2260 |
"/ -ZipIt Macintosh Extra Field (long) (0x2605): |
|
2261 |
"/ |
|
2262 |
"/ The following is the layout of the ZipIt extra block |
|
2263 |
"/ for Macintosh. The local-header and central-header versions |
|
2264 |
"/ are identical. This block must be present if the file is |
|
2265 |
"/ stored MacBinary-encoded and it should not be used if the file |
|
2266 |
"/ is not stored MacBinary-encoded. |
|
2267 |
"/ |
|
2268 |
"/ Value Size Description |
|
2269 |
"/ ----- ---- ----------- |
|
2270 |
"/ (Mac2) 0x2605 Short tag for this extra block type |
|
2271 |
"/ TSize Short total data size for this block |
|
2272 |
"/ "ZPIT" beLong extra-field signature |
|
2273 |
"/ FnLen Byte length of FileName |
|
2274 |
"/ FileName variable full Macintosh filename |
|
2275 |
"/ FileType Byte[4] four-byte Mac file type string |
|
2276 |
"/ Creator Byte[4] four-byte Mac creator string |
|
2277 |
"/ |
|
2278 |
"/ |
|
2279 |
"/ -ZipIt Macintosh Extra Field (short, for files) (0x2705): |
|
2280 |
"/ |
|
2281 |
"/ The following is the layout of a shortened variant of the |
|
2282 |
"/ ZipIt extra block for Macintosh (without "full name" entry). |
|
2283 |
"/ This variant is used by ZipIt 1.3.5 and newer for entries of |
|
2284 |
"/ files (not directories) that do not have a MacBinary encoded |
|
2285 |
"/ file. The local-header and central-header versions are identical. |
|
2286 |
"/ |
|
2287 |
"/ Value Size Description |
|
2288 |
"/ ----- ---- ----------- |
|
2289 |
"/ (Mac2b) 0x2705 Short tag for this extra block type |
|
2290 |
"/ TSize Short total data size for this block (12) |
|
2291 |
"/ "ZPIT" beLong extra-field signature |
|
2292 |
"/ FileType Byte[4] four-byte Mac file type string |
|
2293 |
"/ Creator Byte[4] four-byte Mac creator string |
|
2294 |
"/ fdFlags beShort attributes from FInfo.frFlags, |
|
2295 |
"/ may be omitted |
|
2296 |
"/ 0x0000 beShort reserved, may be omitted |
|
2297 |
"/ |
|
2298 |
"/ |
|
2299 |
"/ -ZipIt Macintosh Extra Field (short, for directories) (0x2805): |
|
2300 |
"/ |
|
2301 |
"/ The following is the layout of a shortened variant of the |
|
2302 |
"/ ZipIt extra block for Macintosh used only for directory |
|
2303 |
"/ entries. This variant is used by ZipIt 1.3.5 and newer to |
|
2304 |
"/ save some optional Mac-specific information about directories. |
|
2305 |
"/ The local-header and central-header versions are identical. |
|
2306 |
"/ |
|
2307 |
"/ Value Size Description |
|
2308 |
"/ ----- ---- ----------- |
|
2309 |
"/ (Mac2c) 0x2805 Short tag for this extra block type |
|
2310 |
"/ TSize Short total data size for this block (12) |
|
2311 |
"/ "ZPIT" beLong extra-field signature |
|
2312 |
"/ frFlags beShort attributes from DInfo.frFlags, may |
|
2313 |
"/ be omitted |
|
2314 |
"/ View beShort ZipIt view flag, may be omitted |
|
2315 |
"/ |
|
2316 |
"/ |
|
2317 |
"/ The View field specifies ZipIt-internal settings as follows: |
|
2318 |
"/ |
|
2319 |
"/ Bits of the Flags: |
|
2320 |
"/ bit 0 if set, the folder is shown expanded (open) |
|
2321 |
"/ when the archive contents are viewed in ZipIt. |
|
2322 |
"/ bits 1-15 reserved, zero; |
|
2323 |
"/ |
|
2324 |
"/ |
|
2325 |
"/ -FWKCS MD5 Extra Field (0x4b46): |
|
2326 |
"/ |
|
2327 |
"/ The FWKCS Contents_Signature System, used in |
|
2328 |
"/ automatically identifying files independent of file name, |
|
2329 |
"/ optionally adds and uses an extra field to support the |
|
2330 |
"/ rapid creation of an enhanced contents_signature: |
|
2331 |
"/ |
|
2332 |
"/ Header ID = 0x4b46 |
|
2333 |
"/ Data Size = 0x0013 |
|
2334 |
"/ Preface = 'M','D','5' |
|
2335 |
"/ followed by 16 bytes containing the uncompressed file's |
|
2336 |
"/ 128_bit MD5 hash(1), low byte first. |
|
2337 |
"/ |
|
2338 |
"/ When FWKCS revises a .ZIP file central directory to add |
|
2339 |
"/ this extra field for a file, it also replaces the |
|
2340 |
"/ central directory entry for that file's uncompressed |
|
2341 |
"/ file length with a measured value. |
|
2342 |
"/ |
|
2343 |
"/ FWKCS provides an option to strip this extra field, if |
|
2344 |
"/ present, from a .ZIP file central directory. In adding |
|
2345 |
"/ this extra field, FWKCS preserves .ZIP file Authenticity |
|
2346 |
"/ Verification; if stripping this extra field, FWKCS |
|
2347 |
"/ preserves all versions of AV through PKZIP version 2.04g. |
|
2348 |
"/ |
|
2349 |
"/ FWKCS, and FWKCS Contents_Signature System, are |
|
2350 |
"/ trademarks of Frederick W. Kantor. |
|
2351 |
"/ |
|
2352 |
"/ (1) R. Rivest, RFC1321.TXT, MIT Laboratory for Computer |
|
2353 |
"/ Science and RSA Data Security, Inc., April 1992. |
|
2354 |
"/ ll.76-77: "The MD5 algorithm is being placed in the |
|
2355 |
"/ public domain for review and possible adoption as a |
|
2356 |
"/ standard." |
|
2357 |
"/ |
|
2358 |
"/ |
|
2359 |
"/ -Info-ZIP Unicode Comment Extra Field (0x6375): |
|
2360 |
"/ |
|
2361 |
"/ Stores the UTF-8 version of the file comment as stored in the |
|
2362 |
"/ central directory header. (Last Revision 20070912) |
|
2363 |
"/ |
|
2364 |
"/ Value Size Description |
|
2365 |
"/ ----- ---- ----------- |
|
2366 |
"/ (UCom) 0x6375 Short tag for this extra block type ("uc") |
|
2367 |
"/ TSize Short total data size for this block |
|
2368 |
"/ Version 1 byte version of this extra field, currently 1 |
|
2369 |
"/ ComCRC32 4 bytes Comment Field CRC32 Checksum |
|
2370 |
"/ UnicodeCom Variable UTF-8 version of the entry comment |
|
2371 |
"/ |
|
2372 |
"/ Currently Version is set to the number 1. If there is a need |
|
2373 |
"/ to change this field, the version will be incremented. Changes |
|
2374 |
"/ may not be backward compatible so this extra field should not be |
|
2375 |
"/ used if the version is not recognized. |
|
2376 |
"/ |
|
2377 |
"/ The ComCRC32 is the standard zip CRC32 checksum of the File Comment |
|
2378 |
"/ field in the central directory header. This is used to verify that |
|
2379 |
"/ the comment field has not changed since the Unicode Comment extra field |
|
2380 |
"/ was created. This can happen if a utility changes the File Comment |
|
2381 |
"/ field but does not update the UTF-8 Comment extra field. If the CRC |
|
2382 |
"/ check fails, this Unicode Comment extra field should be ignored and |
|
2383 |
"/ the File Comment field in the header should be used instead. |
|
2384 |
"/ |
|
2385 |
"/ The UnicodeCom field is the UTF-8 version of the File Comment field |
|
2386 |
"/ in the header. As UnicodeCom is defined to be UTF-8, no UTF-8 byte |
|
2387 |
"/ order mark (BOM) is used. The length of this field is determined by |
|
2388 |
"/ subtracting the size of the previous fields from TSize. If both the |
|
2389 |
"/ File Name and Comment fields are UTF-8, the new General Purpose Bit |
|
2390 |
"/ Flag, bit 11 (Language encoding flag (EFS)), can be used to indicate |
|
2391 |
"/ both the header File Name and Comment fields are UTF-8 and, in this |
|
2392 |
"/ case, the Unicode Path and Unicode Comment extra fields are not |
|
2393 |
"/ needed and should not be created. Note that, for backward |
|
2394 |
"/ compatibility, bit 11 should only be used if the native character set |
|
2395 |
"/ of the paths and comments being zipped up are already in UTF-8. It is |
|
2396 |
"/ expected that the same file comment storage method, either general |
|
2397 |
"/ purpose bit 11 or extra fields, be used in both the Local and Central |
|
2398 |
"/ Directory Header for a file. |
|
2399 |
"/ |
|
2400 |
"/ |
|
2401 |
"/ -Info-ZIP Unicode Path Extra Field (0x7075): |
|
2402 |
"/ |
|
2403 |
"/ Stores the UTF-8 version of the file name field as stored in the |
|
2404 |
"/ local header and central directory header. (Last Revision 20070912) |
|
2405 |
"/ |
|
2406 |
"/ Value Size Description |
|
2407 |
"/ ----- ---- ----------- |
|
2408 |
"/ (UPath) 0x7075 Short tag for this extra block type ("up") |
|
2409 |
"/ TSize Short total data size for this block |
|
2410 |
"/ Version 1 byte version of this extra field, currently 1 |
|
2411 |
"/ NameCRC32 4 bytes File Name Field CRC32 Checksum |
|
2412 |
"/ UnicodeName Variable UTF-8 version of the entry File Name |
|
2413 |
"/ |
|
2414 |
"/ Currently Version is set to the number 1. If there is a need |
|
2415 |
"/ to change this field, the version will be incremented. Changes |
|
2416 |
"/ may not be backward compatible so this extra field should not be |
|
2417 |
"/ used if the version is not recognized. |
|
2418 |
"/ |
|
2419 |
"/ The NameCRC32 is the standard zip CRC32 checksum of the File Name |
|
2420 |
"/ field in the header. This is used to verify that the header |
|
2421 |
"/ File Name field has not changed since the Unicode Path extra field |
|
2422 |
"/ was created. This can happen if a utility renames the File Name but |
|
2423 |
"/ does not update the UTF-8 path extra field. If the CRC check fails, |
|
2424 |
"/ this UTF-8 Path Extra Field should be ignored and the File Name field |
|
2425 |
"/ in the header should be used instead. |
|
2426 |
"/ |
|
2427 |
"/ The UnicodeName is the UTF-8 version of the contents of the File Name |
|
2428 |
"/ field in the header. As UnicodeName is defined to be UTF-8, no UTF-8 |
|
2429 |
"/ byte order mark (BOM) is used. The length of this field is determined |
|
2430 |
"/ by subtracting the size of the previous fields from TSize. If both |
|
2431 |
"/ the File Name and Comment fields are UTF-8, the new General Purpose |
|
2432 |
"/ Bit Flag, bit 11 (Language encoding flag (EFS)), can be used to |
|
2433 |
"/ indicate that both the header File Name and Comment fields are UTF-8 |
|
2434 |
"/ and, in this case, the Unicode Path and Unicode Comment extra fields |
|
2435 |
"/ are not needed and should not be created. Note that, for backward |
|
2436 |
"/ compatibility, bit 11 should only be used if the native character set |
|
2437 |
"/ of the paths and comments being zipped up are already in UTF-8. It is |
|
2438 |
"/ expected that the same file name storage method, either general |
|
2439 |
"/ purpose bit 11 or extra fields, be used in both the Local and Central |
|
2440 |
"/ Directory Header for a file. |
|
2441 |
"/ |
|
2442 |
"/ |
|
2443 |
"/ -Microsoft Open Packaging Growth Hint (0xa220): |
|
2444 |
"/ |
|
2445 |
"/ Value Size Description |
|
2446 |
"/ ----- ---- ----------- |
|
2447 |
"/ 0xa220 Short tag for this extra block type |
|
2448 |
"/ TSize Short size of Sig + PadVal + Padding |
|
2449 |
"/ Sig Short verification signature (A028) |
|
2450 |
"/ PadVal Short Initial padding value |
|
2451 |
"/ Padding variable filled with NULL characters |
|
2452 |
"/ |
|
2453 |
"/ |
|
2454 |
"/ file comment: (Variable) |
|
2455 |
"/ |
|
2456 |
"/ The comment for this file. |
|
2457 |
"/ |
|
2458 |
"/ number of this disk: (2 bytes) |
|
2459 |
"/ |
|
2460 |
"/ The number of this disk, which contains central |
|
2461 |
"/ directory end record. If an archive is in ZIP64 format |
|
2462 |
"/ and the value in this field is 0xFFFF, the size will |
|
2463 |
"/ be in the corresponding 4 byte zip64 end of central |
|
2464 |
"/ directory field. |
|
2465 |
"/ |
|
2466 |
"/ |
|
2467 |
"/ number of the disk with the start of the central |
|
2468 |
"/ directory: (2 bytes) |
|
2469 |
"/ |
|
2470 |
"/ The number of the disk on which the central |
|
2471 |
"/ directory starts. If an archive is in ZIP64 format |
|
2472 |
"/ and the value in this field is 0xFFFF, the size will |
|
2473 |
"/ be in the corresponding 4 byte zip64 end of central |
|
2474 |
"/ directory field. |
|
2475 |
"/ |
|
2476 |
"/ total number of entries in the central dir on |
|
2477 |
"/ this disk: (2 bytes) |
|
2478 |
"/ |
|
2479 |
"/ The number of central directory entries on this disk. |
|
2480 |
"/ If an archive is in ZIP64 format and the value in |
|
2481 |
"/ this field is 0xFFFF, the size will be in the |
|
2482 |
"/ corresponding 8 byte zip64 end of central |
|
2483 |
"/ directory field. |
|
2484 |
"/ |
|
2485 |
"/ total number of entries in the central dir: (2 bytes) |
|
2486 |
"/ |
|
2487 |
"/ The total number of files in the .ZIP file. If an |
|
2488 |
"/ archive is in ZIP64 format and the value in this field |
|
2489 |
"/ is 0xFFFF, the size will be in the corresponding 8 byte |
|
2490 |
"/ zip64 end of central directory field. |
|
2491 |
"/ |
|
2492 |
"/ size of the central directory: (4 bytes) |
|
2493 |
"/ |
|
2494 |
"/ The size (in bytes) of the entire central directory. |
|
2495 |
"/ If an archive is in ZIP64 format and the value in |
|
2496 |
"/ this field is 0xFFFFFFFF, the size will be in the |
|
2497 |
"/ corresponding 8 byte zip64 end of central |
|
2498 |
"/ directory field. |
|
2499 |
"/ |
|
2500 |
"/ offset of start of central directory with respect to |
|
2501 |
"/ the starting disk number: (4 bytes) |
|
2502 |
"/ |
|
2503 |
"/ Offset of the start of the central directory on the |
|
2504 |
"/ disk on which the central directory starts. If an |
|
2505 |
"/ archive is in ZIP64 format and the value in this |
|
2506 |
"/ field is 0xFFFFFFFF, the size will be in the |
|
2507 |
"/ corresponding 8 byte zip64 end of central |
|
2508 |
"/ directory field. |
|
2509 |
"/ |
|
2510 |
"/ .ZIP file comment length: (2 bytes) |
|
2511 |
"/ |
|
2512 |
"/ The length of the comment for this .ZIP file. |
|
2513 |
"/ |
|
2514 |
"/ .ZIP file comment: (Variable) |
|
2515 |
"/ |
|
2516 |
"/ The comment for this .ZIP file. ZIP file comment data |
|
2517 |
"/ is stored unsecured. No encryption or data authentication |
|
2518 |
"/ is applied to this area at this time. Confidential information |
|
2519 |
"/ should not be stored in this section. |
|
2520 |
"/ |
|
2521 |
"/ zip64 extensible data sector (variable size) |
|
2522 |
"/ |
|
2523 |
"/ (currently reserved for use by PKWARE) |
|
2524 |
"/ |
|
2525 |
"/ |
|
2526 |
"/ K. Splitting and Spanning ZIP files |
|
2527 |
"/ |
|
2528 |
"/ Spanning is the process of segmenting a ZIP file across |
|
2529 |
"/ multiple removable media. This support has typically only |
|
2530 |
"/ been provided for DOS formatted floppy diskettes. |
|
2531 |
"/ |
|
2532 |
"/ File splitting is a newer derivative of spanning. |
|
2533 |
"/ Splitting follows the same segmentation process as |
|
2534 |
"/ spanning, however, it does not require writing each |
|
2535 |
"/ segment to a unique removable medium and instead supports |
|
2536 |
"/ placing all pieces onto local or non-removable locations |
|
2537 |
"/ such as file systems, local drives, folders, etc... |
|
2538 |
"/ |
|
2539 |
"/ A key difference between spanned and split ZIP files is |
|
2540 |
"/ that all pieces of a spanned ZIP file have the same name. |
|
2541 |
"/ Since each piece is written to a separate volume, no name |
|
2542 |
"/ collisions occur and each segment can reuse the original |
|
2543 |
"/ .ZIP file name given to the archive. |
|
2544 |
"/ |
|
2545 |
"/ Sequence ordering for DOS spanned archives uses the DOS |
|
2546 |
"/ volume label to determine segment numbers. Volume labels |
|
2547 |
"/ for each segment are written using the form PKBACK#xxx, |
|
2548 |
"/ where xxx is the segment number written as a decimal |
|
2549 |
"/ value from 001 - nnn. |
|
2550 |
"/ |
|
2551 |
"/ Split ZIP files are typically written to the same location |
|
2552 |
"/ and are subject to name collisions if the spanned name |
|
2553 |
"/ format is used since each segment will reside on the same |
|
2554 |
"/ drive. To avoid name collisions, split archives are named |
|
2555 |
"/ as follows. |
|
2556 |
"/ |
|
2557 |
"/ Segment 1 = filename.z01 |
|
2558 |
"/ Segment n-1 = filename.z(n-1) |
|
2559 |
"/ Segment n = filename.zip |
|
2560 |
"/ |
|
2561 |
"/ The .ZIP extension is used on the last segment to support |
|
2562 |
"/ quickly reading the central directory. The segment number |
|
2563 |
"/ n should be a decimal value. |
|
2564 |
"/ |
|
2565 |
"/ Spanned ZIP files may be PKSFX Self-extracting ZIP files. |
|
2566 |
"/ PKSFX files may also be split, however, in this case |
|
2567 |
"/ the first segment must be named filename.exe. The first |
|
2568 |
"/ segment of a split PKSFX archive must be large enough to |
|
2569 |
"/ include the entire executable program. |
|
2570 |
"/ |
|
2571 |
"/ Capacities for split archives are as follows. |
|
2572 |
"/ |
|
2573 |
"/ Maximum number of segments = 4,294,967,295 - 1 |
|
2574 |
"/ Maximum .ZIP segment size = 4,294,967,295 bytes |
|
2575 |
"/ Minimum segment size = 64K |
|
2576 |
"/ Maximum PKSFX segment size = 2,147,483,647 bytes |
|
2577 |
"/ |
|
2578 |
"/ Segment sizes may be |
|
622 | 2579 |
! ! |
2580 |
||
2581 |
!ZipArchive class methodsFor:'instance creation'! |
|
2582 |
||
2583 |
newFileNamed:name |
|
2584 |
^ self new name:name mode:#write |
|
2585 |
||
2586 |
"Created: / 29.3.1998 / 17:46:16 / cg" |
|
2587 |
! |
|
2588 |
||
2589 |
oldFileNamed:name |
|
635 | 2590 |
|zar f fn| |
628
27102a6bd3f7
remember recently visited zipArchives for faster access
Claus Gittinger <cg@exept.de>
parents:
625
diff
changeset
|
2591 |
|
27102a6bd3f7
remember recently visited zipArchives for faster access
Claus Gittinger <cg@exept.de>
parents:
625
diff
changeset
|
2592 |
RecentlyUsedZipArchives isNil ifTrue:[ |
1839 | 2593 |
RecentlyUsedZipArchives := OrderedCollection new |
628
27102a6bd3f7
remember recently visited zipArchives for faster access
Claus Gittinger <cg@exept.de>
parents:
625
diff
changeset
|
2594 |
]. |
635 | 2595 |
f := name asFilename. |
953 | 2596 |
f exists ifFalse:[^ nil]. |
2597 |
||
635 | 2598 |
fn := f pathName. |
628
27102a6bd3f7
remember recently visited zipArchives for faster access
Claus Gittinger <cg@exept.de>
parents:
625
diff
changeset
|
2599 |
RecentlyUsedZipArchives keysAndValuesDo:[:i :z | |
1839 | 2600 |
z name = fn ifTrue:[ |
2601 |
RecentlyUsedZipArchives removeIndex:i. |
|
2602 |
RecentlyUsedZipArchives addLast:z. |
|
2603 |
self installFlushBlock. |
|
2604 |
^ z |
|
2605 |
]. |
|
628
27102a6bd3f7
remember recently visited zipArchives for faster access
Claus Gittinger <cg@exept.de>
parents:
625
diff
changeset
|
2606 |
]. |
635 | 2607 |
zar := self new name:fn mode:#read. |
628
27102a6bd3f7
remember recently visited zipArchives for faster access
Claus Gittinger <cg@exept.de>
parents:
625
diff
changeset
|
2608 |
RecentlyUsedZipArchives add:zar. |
701
90faf30c20eb
increased number of cached zipFiles
Claus Gittinger <cg@exept.de>
parents:
700
diff
changeset
|
2609 |
[RecentlyUsedZipArchives size > 15] whileTrue:[ |
1839 | 2610 |
RecentlyUsedZipArchives removeFirst |
628
27102a6bd3f7
remember recently visited zipArchives for faster access
Claus Gittinger <cg@exept.de>
parents:
625
diff
changeset
|
2611 |
]. |
638
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
2612 |
self installFlushBlock. |
628
27102a6bd3f7
remember recently visited zipArchives for faster access
Claus Gittinger <cg@exept.de>
parents:
625
diff
changeset
|
2613 |
^ zar |
622 | 2614 |
|
2615 |
"Created: / 29.3.1998 / 17:46:09 / cg" |
|
701
90faf30c20eb
increased number of cached zipFiles
Claus Gittinger <cg@exept.de>
parents:
700
diff
changeset
|
2616 |
"Modified: / 20.10.1998 / 00:30:02 / cg" |
622 | 2617 |
! ! |
2618 |
||
2619 |
!ZipArchive class methodsFor:'class initialization'! |
|
2620 |
||
2621 |
initialize |
|
2622 |
ECREC_SIZE := 18. |
|
2623 |
LREC_SIZE := 26. |
|
2624 |
CREC_SIZE := 42. |
|
2625 |
||
2626 |
TOTAL_ENTRIES_CENTRAL_DIR := 10. |
|
2627 |
SIZE_CENTRAL_DIRECTORY := 12. |
|
2628 |
||
2629 |
C_COMPRESSED_SIZE := 16. |
|
2630 |
C_UNCOMPRESSED_SIZE := 20. |
|
2631 |
C_FILENAME_LENGTH := 24. |
|
2632 |
C_RELATIVE_OFFSET_LOCAL_HEADER := 38. |
|
2633 |
||
938
4544b3c105fe
fixed directory reading (care for comment and extra-header bytes)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
2634 |
C_LOCALHEADERSIGNATURE := 16r04034b50. |
4544b3c105fe
fixed directory reading (care for comment and extra-header bytes)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
2635 |
C_CENTRALHEADERSIGNATURE := 16r02014b50. |
4544b3c105fe
fixed directory reading (care for comment and extra-header bytes)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
2636 |
C_CENTRALENDSIGNATURE := 16r06054b50. |
4544b3c105fe
fixed directory reading (care for comment and extra-header bytes)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
2637 |
|
1839 | 2638 |
"/ compression methods |
2639 |
COMPR_STORED := 0. |
|
622 | 2640 |
COMPR_SHRUNK := 1. |
2641 |
COMPR_REDUCED1 := 2. |
|
2642 |
COMPR_REDUCED2 := 3. |
|
2643 |
COMPR_REDUCED3 := 4. |
|
2644 |
COMPR_REDUCED4 := 5. |
|
2645 |
COMPR_IMPLODED := 6. |
|
2646 |
COMPR_TOKENIZED := 7. |
|
2647 |
COMPR_DEFLATED := 8. |
|
2648 |
||
938
4544b3c105fe
fixed directory reading (care for comment and extra-header bytes)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
2649 |
ZipFileFormatErrorSignal isNil ifTrue:[ |
1839 | 2650 |
ZipFileFormatErrorSignal := Error newSignalMayProceed:true. |
2651 |
ZipFileFormatErrorSignal nameClass:self message:#zipFileFormatErrorSignal. |
|
2652 |
ZipFileFormatErrorSignal notifierString:'unrecognized/bad zip file format'. |
|
938
4544b3c105fe
fixed directory reading (care for comment and extra-header bytes)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
2653 |
]. |
622 | 2654 |
|
2655 |
" |
|
2656 |
self initialize |
|
2657 |
" |
|
2658 |
||
2659 |
"Modified: / 29.3.1998 / 20:17:18 / cg" |
|
2660 |
! ! |
|
2661 |
||
629
33fcaf60afa3
remember recently visited zipArchives for faster access
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
2662 |
!ZipArchive class methodsFor:'cleanup'! |
33fcaf60afa3
remember recently visited zipArchives for faster access
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
2663 |
|
900 | 2664 |
flush |
2665 |
"forget about cached zipArchives" |
|
2666 |
||
2667 |
RecentlyUsedZipArchives := nil. FlushBlock := nil. |
|
2668 |
||
2669 |
" |
|
2670 |
self flush |
|
2671 |
" |
|
2672 |
! |
|
2673 |
||
638
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
2674 |
installFlushBlock |
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
2675 |
"forget about cached zipArchives" |
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
2676 |
|
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
2677 |
FlushBlock isNil ifTrue:[ |
1839 | 2678 |
FlushBlock := [ RecentlyUsedZipArchives := nil. FlushBlock := nil. ]. |
700
b1c6920cfef6
keep more zipArchive-dirs cached.
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2679 |
] ifFalse:[ |
1839 | 2680 |
Processor removeTimedBlock:FlushBlock. |
638
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
2681 |
]. |
641 | 2682 |
Processor addTimedBlock:FlushBlock for:nil afterSeconds:60. |
638
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
2683 |
|
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
2684 |
" |
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
2685 |
self installFlushBlock |
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
2686 |
" |
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
2687 |
|
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
2688 |
"Created: / 9.4.1998 / 13:17:07 / cg" |
700
b1c6920cfef6
keep more zipArchive-dirs cached.
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2689 |
"Modified: / 19.10.1998 / 21:02:22 / cg" |
638
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
2690 |
! |
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
2691 |
|
629
33fcaf60afa3
remember recently visited zipArchives for faster access
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
2692 |
lowSpaceCleanup |
635 | 2693 |
"forget about cached zipArchives" |
2694 |
||
629
33fcaf60afa3
remember recently visited zipArchives for faster access
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
2695 |
RecentlyUsedZipArchives := nil |
33fcaf60afa3
remember recently visited zipArchives for faster access
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
2696 |
|
635 | 2697 |
" |
2698 |
self lowSpaceCleanup |
|
2699 |
" |
|
2700 |
||
2701 |
"Modified: / 7.4.1998 / 17:58:57 / cg" |
|
629
33fcaf60afa3
remember recently visited zipArchives for faster access
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
2702 |
! ! |
33fcaf60afa3
remember recently visited zipArchives for faster access
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
2703 |
|
622 | 2704 |
!ZipArchive class methodsFor:'constants'! |
2705 |
||
2706 |
LREC_SIZE |
|
2707 |
^ LREC_SIZE |
|
2708 |
||
2709 |
"Created: / 29.3.1998 / 19:11:20 / cg" |
|
2710 |
! ! |
|
2711 |
||
766
4c422664dcc8
care for bad zipFile entries.
Claus Gittinger <cg@exept.de>
parents:
726
diff
changeset
|
2712 |
!ZipArchive class methodsFor:'debugging'! |
4c422664dcc8
care for bad zipFile entries.
Claus Gittinger <cg@exept.de>
parents:
726
diff
changeset
|
2713 |
|
4c422664dcc8
care for bad zipFile entries.
Claus Gittinger <cg@exept.de>
parents:
726
diff
changeset
|
2714 |
debugTrace:aBoolean |
4c422664dcc8
care for bad zipFile entries.
Claus Gittinger <cg@exept.de>
parents:
726
diff
changeset
|
2715 |
%{ |
4c422664dcc8
care for bad zipFile entries.
Claus Gittinger <cg@exept.de>
parents:
726
diff
changeset
|
2716 |
if (aBoolean == true) { |
1839 | 2717 |
debugTrace = 1; |
766
4c422664dcc8
care for bad zipFile entries.
Claus Gittinger <cg@exept.de>
parents:
726
diff
changeset
|
2718 |
} else { |
1839 | 2719 |
debugTrace = 0; |
766
4c422664dcc8
care for bad zipFile entries.
Claus Gittinger <cg@exept.de>
parents:
726
diff
changeset
|
2720 |
} |
4c422664dcc8
care for bad zipFile entries.
Claus Gittinger <cg@exept.de>
parents:
726
diff
changeset
|
2721 |
%} |
4c422664dcc8
care for bad zipFile entries.
Claus Gittinger <cg@exept.de>
parents:
726
diff
changeset
|
2722 |
! ! |
4c422664dcc8
care for bad zipFile entries.
Claus Gittinger <cg@exept.de>
parents:
726
diff
changeset
|
2723 |
|
622 | 2724 |
!ZipArchive methodsFor:'accessing'! |
2725 |
||
2726 |
entries |
|
2727 |
"return a collection of fileName entries" |
|
2728 |
||
2729 |
|names| |
|
2730 |
||
2731 |
names := OrderedCollection new. |
|
2732 |
||
2733 |
self zipMembersDo:[:zipd | |
|
1979 | 2734 |
names add:(zipd fileName) |
622 | 2735 |
]. |
2736 |
^ names |
|
2737 |
||
2738 |
" |
|
2739 |
(ZipArchive oldFileNamed:'/usr/lib/java/lib/classes.zip') entries |
|
2740 |
" |
|
2741 |
||
2742 |
"Modified: / 29.3.1998 / 20:08:38 / cg" |
|
2743 |
! |
|
2744 |
||
2745 |
extract:fileName |
|
767 | 2746 |
"extract a filename entry as a byteArray; |
2747 |
nil on errors" |
|
636 | 2748 |
|
719 | 2749 |
|zmemb rawContents data oldEntry| |
638
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
2750 |
|
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
2751 |
recentlyExtractedEntries isNil ifTrue:[ |
1979 | 2752 |
recentlyExtractedEntries := OrderedCollection new |
638
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
2753 |
]. |
1979 | 2754 |
|
2755 |
"/ recentlyExtractedEntries keysAndValuesDo:[:index :entry | |
|
2756 |
"/ (entry notNil and:[entry fileName = fileName]) ifTrue:[ |
|
2757 |
"/ recentlyExtractedEntries removeIndex:index. |
|
2758 |
"/ recentlyExtractedEntries addLast:entry. |
|
2759 |
"/ data := entry data. |
|
2760 |
"/ data notNil ifTrue:[ |
|
2761 |
"/ ^ data |
|
2762 |
"/ ] |
|
2763 |
"/ ] |
|
2764 |
"/ ]. |
|
622 | 2765 |
|
2766 |
zmemb := self findMember:fileName. |
|
625 | 2767 |
zmemb isNil ifTrue:[^ nil]. |
2768 |
||
2769 |
self openFile. |
|
1150
e9fe3696d93d
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1149
diff
changeset
|
2770 |
file position0Based:(zmemb fileStart). |
1979 | 2771 |
rawContents := file nextBytes:(zmemb compressedSize). |
625 | 2772 |
self closeFile. |
638
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
2773 |
|
1979 | 2774 |
"/ data := ByteArray new: (zmemb uncompressedSize). |
2775 |
"/ ZipStream uncompress: rawContents into: data. |
|
2776 |
"/ self halt. |
|
1839 | 2777 |
data := self |
1979 | 2778 |
decode:rawContents |
2779 |
method:(zmemb compressionMethod) |
|
2780 |
size:(zmemb uncompressedSize). |
|
2781 |
||
2782 |
||
2783 |
"/ data size < (32*1024) ifTrue:[ |
|
2784 |
"/"/ zmemb data:data. |
|
2785 |
"/ recentlyExtractedEntries addLast:zmemb. |
|
2786 |
"/ [recentlyExtractedEntries size > 5] whileTrue:[ |
|
2787 |
"/ oldEntry := recentlyExtractedEntries removeFirst. |
|
2788 |
"/ oldEntry data:nil. |
|
2789 |
"/ ]. |
|
2790 |
"/ ]. |
|
638
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
2791 |
^ data. |
622 | 2792 |
|
2793 |
" |
|
2794 |
(ZipArchive oldFileNamed:'/usr/lib/java/lib/classes.zip') extract:'java/io/UTFDataFormatException.class' |
|
2795 |
" |
|
2796 |
||
719 | 2797 |
"Modified: / 10.1.1999 / 17:43:25 / cg" |
622 | 2798 |
! |
2799 |
||
2800 |
members |
|
2801 |
"return a collection of members" |
|
2802 |
||
2803 |
|members| |
|
2804 |
||
2805 |
members := OrderedCollection new. |
|
2806 |
||
2807 |
self zipMembersDo:[:zipd | |
|
1839 | 2808 |
members add:zipd |
622 | 2809 |
]. |
2810 |
^ members |
|
2811 |
||
2812 |
" |
|
2813 |
(ZipArchive oldFileNamed:'/usr/lib/java/lib/classes.zip') members |
|
2814 |
" |
|
2815 |
||
2816 |
"Created: / 29.3.1998 / 20:09:27 / cg" |
|
2817 |
"Modified: / 29.3.1998 / 20:10:21 / cg" |
|
628
27102a6bd3f7
remember recently visited zipArchives for faster access
Claus Gittinger <cg@exept.de>
parents:
625
diff
changeset
|
2818 |
! |
27102a6bd3f7
remember recently visited zipArchives for faster access
Claus Gittinger <cg@exept.de>
parents:
625
diff
changeset
|
2819 |
|
27102a6bd3f7
remember recently visited zipArchives for faster access
Claus Gittinger <cg@exept.de>
parents:
625
diff
changeset
|
2820 |
name |
636 | 2821 |
"return the (file-)name of this zipArchive" |
2822 |
||
628
27102a6bd3f7
remember recently visited zipArchives for faster access
Claus Gittinger <cg@exept.de>
parents:
625
diff
changeset
|
2823 |
^ archiveName |
27102a6bd3f7
remember recently visited zipArchives for faster access
Claus Gittinger <cg@exept.de>
parents:
625
diff
changeset
|
2824 |
|
27102a6bd3f7
remember recently visited zipArchives for faster access
Claus Gittinger <cg@exept.de>
parents:
625
diff
changeset
|
2825 |
"Created: / 6.4.1998 / 10:47:11 / cg" |
622 | 2826 |
! ! |
2827 |
||
2828 |
!ZipArchive methodsFor:'private'! |
|
2829 |
||
625 | 2830 |
closeFile |
717 | 2831 |
file notNil ifTrue:[ |
1839 | 2832 |
file close. |
2833 |
file := nil. |
|
717 | 2834 |
] |
625 | 2835 |
|
2836 |
"Created: / 30.3.1998 / 18:18:10 / cg" |
|
717 | 2837 |
"Modified: / 29.12.1998 / 23:08:27 / cg" |
625 | 2838 |
! |
2839 |
||
624 | 2840 |
name:nm mode:m |
625 | 2841 |
archiveName := nm asFilename name. |
624 | 2842 |
mode := m. |
2843 |
||
952 | 2844 |
mode ~~ #write ifTrue:[ |
1839 | 2845 |
self openFile. |
2846 |
self readDirectory. |
|
2847 |
self closeFile. |
|
622 | 2848 |
] ifFalse:[ |
1839 | 2849 |
"/ self openFile. |
622 | 2850 |
] |
2851 |
||
2852 |
" |
|
2853 |
ZipArchive oldFileNamed:'/usr/lib/java/lib/classes.zip' |
|
2854 |
(ZipArchive oldFileNamed:'/usr/lib/java/lib/classes.zip') entries |
|
2855 |
(ZipArchive oldFileNamed:'/usr/lib/java/lib/classes.zip') extract:'java/io/UTFDataFormatException.class' |
|
2856 |
" |
|
2857 |
||
625 | 2858 |
"Modified: / 30.3.1998 / 18:19:48 / cg" |
2859 |
! |
|
2860 |
||
2861 |
openFile |
|
1979 | 2862 |
self openFile: false. "/ doTruncate |
2863 |
! |
|
2864 |
||
2865 |
openFile: doTruncate |
|
960 | 2866 |
|fn| |
2867 |
||
625 | 2868 |
file isNil ifTrue:[ |
1979 | 2869 |
fn := archiveName asFilename. |
2870 |
mode ~~ #write ifTrue:[ |
|
2871 |
file := fn readStream. |
|
2872 |
] ifFalse:[ |
|
2873 |
doTruncate ifTrue: [ |
|
2874 |
file := fn writeStream |
|
2875 |
] ifFalse: [ |
|
2876 |
file := fn appendingWriteStream |
|
2877 |
]. |
|
2878 |
]. |
|
2879 |
file binary |
|
625 | 2880 |
]. |
2881 |
||
2882 |
"Created: / 30.3.1998 / 18:18:48 / cg" |
|
2883 |
"Modified: / 30.3.1998 / 18:19:26 / cg" |
|
1979 | 2884 |
! |
2885 |
||
2886 |
truncateAndOpenFile |
|
2887 |
self openFile: true. "/ doTruncate |
|
622 | 2888 |
! ! |
2889 |
||
1199 | 2890 |
!ZipArchive methodsFor:'private-decompression'! |
622 | 2891 |
|
636 | 2892 |
decode:rawBytes method:compressionMethod size:uncompressedSize |
2893 |
|outBytes| |
|
2894 |
||
622 | 2895 |
compressionMethod == COMPR_STORED ifTrue:[ |
1839 | 2896 |
"/ |
2897 |
"/ uncompressed |
|
2898 |
"/ |
|
2899 |
^ rawBytes |
|
622 | 2900 |
]. |
2901 |
||
636 | 2902 |
compressionMethod == COMPR_DEFLATED ifTrue:[ |
1839 | 2903 |
"/ |
2904 |
"/ deflate/inflate algorithm |
|
2905 |
"/ |
|
2906 |
outBytes := ByteArray new:uncompressedSize. |
|
2907 |
^ self inflate:rawBytes to:outBytes |
|
636 | 2908 |
]. |
2909 |
||
2910 |
"/ |
|
2911 |
"/ the other algorithms are not (yet) supported |
|
2912 |
"/ |
|
622 | 2913 |
compressionMethod == COMPR_SHRUNK ifTrue:[ |
1839 | 2914 |
self error:'unsupported compression method: SHRUNK'. |
2915 |
^ nil |
|
622 | 2916 |
]. |
2917 |
compressionMethod == COMPR_REDUCED1 ifTrue:[ |
|
1839 | 2918 |
self error:'unsupported compression method: REDUCED1'. |
2919 |
^ nil |
|
622 | 2920 |
]. |
2921 |
compressionMethod == COMPR_REDUCED2 ifTrue:[ |
|
1839 | 2922 |
self error:'unsupported compression method: REDUCED2'. |
2923 |
^ nil |
|
622 | 2924 |
]. |
2925 |
compressionMethod == COMPR_REDUCED3 ifTrue:[ |
|
1839 | 2926 |
self error:'unsupported compression method: REDUCED3'. |
2927 |
^ nil |
|
622 | 2928 |
]. |
2929 |
compressionMethod == COMPR_REDUCED4 ifTrue:[ |
|
1839 | 2930 |
self error:'unsupported compression method: REDUCED4'. |
2931 |
^ nil |
|
622 | 2932 |
]. |
2933 |
compressionMethod == COMPR_IMPLODED ifTrue:[ |
|
1839 | 2934 |
self error:'unsupported compression method: IMPLODED'. |
2935 |
^ nil |
|
622 | 2936 |
]. |
2937 |
compressionMethod == COMPR_TOKENIZED ifTrue:[ |
|
1839 | 2938 |
self error:'unsupported compression method: TOKENIZED'. |
2939 |
^ nil |
|
622 | 2940 |
]. |
2941 |
||
2942 |
self error:'unsupported compression method'. |
|
2943 |
^ nil |
|
2944 |
||
2945 |
"Created: / 29.3.1998 / 20:14:45 / cg" |
|
636 | 2946 |
"Modified: / 8.4.1998 / 10:31:34 / cg" |
638
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
2947 |
! |
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
2948 |
|
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
2949 |
inflate:inBytes to:outBytes |
723 | 2950 |
|inflateReturnCode| |
638
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
2951 |
|
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
2952 |
%{ /* STACK:32768 */ |
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
2953 |
if (__isByteArray(inBytes) |
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
2954 |
&& __isByteArray(outBytes)) { |
1839 | 2955 |
char *in, *out; |
2956 |
int rc; |
|
638
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
2957 |
|
1839 | 2958 |
in = __ByteArrayInstPtr(inBytes)->ba_element; |
2959 |
out = __ByteArrayInstPtr(outBytes)->ba_element; |
|
638
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
2960 |
|
1839 | 2961 |
if ((rc = stx_inflate(in, out)) == 0) { |
2962 |
RETURN (outBytes); |
|
2963 |
} |
|
2964 |
inflateReturnCode = __MKSMALLINT(rc); |
|
638
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
2965 |
} |
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
2966 |
%}. |
723 | 2967 |
inflateReturnCode notNil ifTrue:[ |
1839 | 2968 |
"/ bad blockType 2 |
2969 |
self error:'inflate error: ' , inflateReturnCode printString |
|
723 | 2970 |
]. |
638
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
2971 |
^ nil. |
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
2972 |
|
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
2973 |
"Created: / 8.4.1998 / 10:31:27 / cg" |
622 | 2974 |
! ! |
2975 |
||
1199 | 2976 |
!ZipArchive methodsFor:'private-directory stuff'! |
622 | 2977 |
|
2978 |
addMember |
|
624 | 2979 |
"add a zipMember" |
2980 |
||
622 | 2981 |
|zmemb | |
2982 |
||
691
5c5cf54ead71
handle errors more gracefully
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
2983 |
self addMember:(zmemb := ZipMember new). |
5c5cf54ead71
handle errors more gracefully
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
2984 |
^ zmemb. |
5c5cf54ead71
handle errors more gracefully
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
2985 |
|
5c5cf54ead71
handle errors more gracefully
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
2986 |
"Created: / 29.3.1998 / 18:22:25 / cg" |
5c5cf54ead71
handle errors more gracefully
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
2987 |
"Modified: / 9.9.1998 / 20:33:32 / cg" |
5c5cf54ead71
handle errors more gracefully
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
2988 |
! |
5c5cf54ead71
handle errors more gracefully
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
2989 |
|
5c5cf54ead71
handle errors more gracefully
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
2990 |
addMember:zmemb |
5c5cf54ead71
handle errors more gracefully
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
2991 |
"add a zipMember" |
5c5cf54ead71
handle errors more gracefully
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
2992 |
|
622 | 2993 |
(firstEntry == nil) ifTrue:[ |
1839 | 2994 |
firstEntry := zmemb |
2995 |
] ifFalse:[ |
|
2996 |
lastEntry next:zmemb. |
|
622 | 2997 |
]. |
2998 |
lastEntry := zmemb. |
|
2999 |
^ zmemb. |
|
3000 |
||
624 | 3001 |
"Modified: / 30.3.1998 / 17:13:20 / cg" |
691
5c5cf54ead71
handle errors more gracefully
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
3002 |
"Created: / 9.9.1998 / 20:33:06 / cg" |
622 | 3003 |
! |
3004 |
||
3005 |
findMember:name |
|
624 | 3006 |
"find a zipMember by name" |
3007 |
||
622 | 3008 |
self zipMembersDo:[:zipd | |
1979 | 3009 |
(zipd fileName = name) ifTrue:[^ zipd]. |
622 | 3010 |
]. |
3011 |
^ nil |
|
3012 |
||
624 | 3013 |
"Modified: / 30.3.1998 / 17:13:30 / cg" |
622 | 3014 |
! |
3015 |
||
3016 |
readDirectory |
|
624 | 3017 |
"read the zip directory into a linked-list of zipMembers" |
3018 |
||
1979 | 3019 |
|size count_in foundPK pos0 dataString| |
622 | 3020 |
|
3021 |
size := file fileSize. |
|
3022 |
(size == 0) ifTrue:[ |
|
1979 | 3023 |
count_in := 0. |
3024 |
^ self |
|
622 | 3025 |
]. |
3026 |
||
3027 |
(size < (ECREC_SIZE+4)) ifTrue:[ |
|
1979 | 3028 |
^ ZipFileFormatErrorSignal raiseRequestErrorString:' - zipfile too short'. |
622 | 3029 |
]. |
3030 |
||
900 | 3031 |
foundPK := false. |
1150
e9fe3696d93d
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1149
diff
changeset
|
3032 |
file position0Based:(pos0 := size - ECREC_SIZE - 4). |
1979 | 3033 |
|
3034 |
"/ set position to end of central directory record |
|
1418
0bfc19132acd
Use #codePoint instead of deprecated #asciiValue
Stefan Vogel <sv@exept.de>
parents:
1199
diff
changeset
|
3035 |
((file next ~~ ($P codePoint)) |
0bfc19132acd
Use #codePoint instead of deprecated #asciiValue
Stefan Vogel <sv@exept.de>
parents:
1199
diff
changeset
|
3036 |
or:[file next ~~ ($K codePoint) |
625 | 3037 |
or:[file next ~~ 8r005 |
3038 |
or:[file next ~~ 8r006]]]) ifTrue:[ |
|
1979 | 3039 |
"/ search for end of central directory signature, this is |
3040 |
"/ necessary if the archive includes a .ZIP file comment |
|
3041 |
file reset. "/ (pos0 - 100). |
|
3042 |
[file atEnd not and:[foundPK not]] whileTrue:[ |
|
3043 |
(file next == ($P codePoint) |
|
3044 |
and:[file next == ($K codePoint) |
|
3045 |
and:[file next == 8r005 |
|
3046 |
and:[file next == 8r006]]]) ifTrue:[ |
|
3047 |
foundPK := true. |
|
3048 |
pos0 := file position0Based - 4. |
|
3049 |
] |
|
3050 |
]. |
|
3051 |
foundPK ifTrue:[ |
|
3052 |
'ZipArchive includes a .ZIP file comment; resynchronized' infoPrintCR. |
|
3053 |
] ifFalse:[ |
|
3054 |
^ ZipFileFormatErrorSignal raiseRequestErrorString:' - invalid zipfile'. |
|
3055 |
] |
|
622 | 3056 |
]. |
3057 |
||
1979 | 3058 |
"/ Now we have found the end of central directory record |
3059 |
centralDirectory := ZipCentralDirectory new. |
|
3060 |
centralDirectory numberOfThisDisk:(file nextUnsignedShortMSB:false). |
|
3061 |
centralDirectory centralDirectoryStartDiskNumber:(file nextUnsignedShortMSB:false). |
|
3062 |
centralDirectory centralDirectoryTotalNoOfEntriesOnThisDisk:(file nextUnsignedShortMSB:false). |
|
3063 |
centralDirectory centralDirectoryTotalNoOfEntries:(file nextUnsignedShortMSB:false). |
|
3064 |
centralDirectory centralDirectorySize:(file nextLongMSB:false). |
|
3065 |
centralDirectory centralDirectoryStartOffset:(file nextLongMSB:false). |
|
3066 |
centralDirectory zipCommentLength:(file nextUnsignedShortMSB:false). |
|
3067 |
centralDirectory zipCommentLength ~~ 0 ifTrue: [ |
|
3068 |
"/ read zip comment |
|
3069 |
centralDirectory zipComment:(dataString := String new:(centralDirectory zipCommentLength)). |
|
3070 |
file nextBytes:(centralDirectory zipCommentLength) into:dataString. |
|
3071 |
]. |
|
3072 |
||
3073 |
"/ set file position to start of central directory |
|
3074 |
file position0Based:(pos0 - (centralDirectory centralDirectorySize)). |
|
3075 |
||
3076 |
count_in := centralDirectory centralDirectoryTotalNoOfEntries. |
|
622 | 3077 |
|
1839 | 3078 |
EndOfStreamNotification handle:[:ex| |
1979 | 3079 |
self warn:'ZipArchive: file format error or short file: ' , |
3080 |
(file isFileStream ifTrue:[file pathName] ifFalse:['inStream']). |
|
3081 |
^ self. |
|
1473
1a6c411ba49f
Better premature end of file handling
Stefan Vogel <sv@exept.de>
parents:
1418
diff
changeset
|
3082 |
] do:[ |
1979 | 3083 |
"/ read central directory entries |
3084 |
0 to:(count_in-1) do:[:i | |
|
3085 |
|zipd filename_length centralFileHeaderSignature relative_offset_local_header |
|
3086 |
posOfNextMember extra crcBytes| |
|
3087 |
||
3088 |
centralFileHeaderSignature := file nextLongMSB:false. |
|
3089 |
centralFileHeaderSignature ~= C_CENTRALHEADERSIGNATURE ifTrue:[ |
|
3090 |
self warn:'ZipArchive: file format error - bad centralHeaderSignature in:' , |
|
3091 |
(file isFileStream ifTrue:[file pathName] ifFalse:['inStream']). |
|
3092 |
^ self. |
|
3093 |
]. |
|
3094 |
||
3095 |
zipd := ZipMember new. |
|
3096 |
||
3097 |
zipd versionMadeBy:(file nextUnsignedShortMSB:false). |
|
3098 |
zipd versionNeedToExtract:(file nextUnsignedShortMSB:false). |
|
3099 |
zipd generalPurposBitFlag:(file nextUnsignedShortMSB:false). |
|
3100 |
zipd compressionMethod:(file nextUnsignedShortMSB:false). |
|
3101 |
zipd lastModFileTime:(file nextUnsignedShortMSB:false). |
|
3102 |
zipd lastModFileDate:(file nextUnsignedShortMSB:false). |
|
3103 |
"/ next long did not work because it could be in that case a signed small integer |
|
3104 |
crcBytes := ByteArray with:file next with:file next with:file next with:file next. |
|
3105 |
zipd crc32: (LargeInteger digitBytes: crcBytes MSB: false). |
|
3106 |
zipd compressedSize:(file nextLongMSB:false). |
|
3107 |
zipd uncompressedSize:(file nextLongMSB:false). |
|
3108 |
zipd fileNameLength:(file nextUnsignedShortMSB:false). |
|
3109 |
zipd extraFieldLength:(file nextUnsignedShortMSB:false). |
|
3110 |
zipd fileCommentLength:(file nextUnsignedShortMSB:false). |
|
3111 |
zipd diskNumberStart:(file nextUnsignedShortMSB:false). |
|
3112 |
zipd internalFileAttributes:(file nextUnsignedShortMSB:false). |
|
3113 |
zipd externalFileAttributes:(file nextLongMSB:false). |
|
3114 |
zipd relativeLocalHeaderOffset:(file nextLongMSB:false). |
|
3115 |
||
3116 |
filename_length := zipd fileNameLength. |
|
3117 |
"/ read file name |
|
3118 |
zipd fileName:(dataString := String new:filename_length). |
|
3119 |
file nextBytes:filename_length into:dataString. |
|
3120 |
||
3121 |
zipd extraFieldLength ~~ 0 ifTrue: [ |
|
3122 |
"/ read extra field |
|
3123 |
zipd extraField:(dataString := String new:(zipd extraFieldLength)). |
|
3124 |
file nextBytes:(zipd extraFieldLength) into:dataString. |
|
3125 |
]. |
|
3126 |
||
3127 |
zipd fileCommentLength ~~ 0 ifTrue: [ |
|
3128 |
"/ read file comment |
|
3129 |
zipd fileComment:(dataString := String new:(zipd fileCommentLength)). |
|
3130 |
file nextBytes:(zipd fileCommentLength) into:dataString. |
|
3131 |
]. |
|
3132 |
||
3133 |
"/ central directory header read is now complete |
|
3134 |
"/ remember this file position (start of next member) |
|
3135 |
"/ posOfNextMember := file position. |
|
3136 |
||
3137 |
"/ reposition in file to get start of data section |
|
3138 |
"/ relative_offset_local_header := zipd relativeLocalHeaderOffset. |
|
3139 |
"/ file position0Based:(relative_offset_local_header + 28). |
|
3140 |
"/ extra := file nextUnsignedShortMSB:false. |
|
3141 |
"/ zipd dataStart:(relative_offset_local_header + "C_SIZEOFLOCALHEADER" 30 + filename_length + extra ). |
|
3142 |
||
3143 |
"/ reposition in file to next member |
|
3144 |
"/ file position:posOfNextMember. |
|
3145 |
||
3146 |
self addMember:zipd. |
|
3147 |
]. |
|
3148 |
||
3149 |
"/ check for digital signature |
|
3150 |
((file next ~~ ($P codePoint)) |
|
3151 |
or:[file next ~~ ($K codePoint) |
|
3152 |
or:[file next ~~ 8r005 |
|
3153 |
or:[file next ~~ 8r005]]]) ifTrue:[ |
|
3154 |
centralDirectory digitalSignatureDataSize:(file nextUnsignedShortMSB:false). |
|
3155 |
centralDirectory digitalSignatureDataSize ~~ 0 ifTrue: [ |
|
3156 |
"/ read digital signature data |
|
3157 |
centralDirectory digitalSignatureData:(dataString := String new:(centralDirectory digitalSignatureDataSize)). |
|
3158 |
file nextBytes:(centralDirectory digitalSignatureDataSize) into:dataString. |
|
3159 |
]. |
|
3160 |
]. |
|
622 | 3161 |
] |
3162 |
||
900 | 3163 |
" |
938
4544b3c105fe
fixed directory reading (care for comment and extra-header bytes)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
3164 |
ZipArchive flush. |
900 | 3165 |
ZipArchive oldFileNamed:'/usr/lib/jdk1.1.7/lib/classes.zip' |
938
4544b3c105fe
fixed directory reading (care for comment and extra-header bytes)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
3166 |
ZipArchive oldFileNamed:'/usr/lib/jdk1.1.8/lib/classes.zip' |
900 | 3167 |
" |
3168 |
||
700
b1c6920cfef6
keep more zipArchive-dirs cached.
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3169 |
"Modified: / 19.10.1998 / 21:27:32 / cg" |
622 | 3170 |
! |
3171 |
||
3172 |
zipMembersDo:aBlock |
|
624 | 3173 |
"evaluate aBlock for all zipMembers" |
3174 |
||
622 | 3175 |
|zipd| |
3176 |
||
3177 |
zipd := firstEntry. |
|
3178 |
[zipd notNil] whileTrue:[ |
|
1839 | 3179 |
aBlock value:zipd. |
3180 |
zipd := zipd next |
|
622 | 3181 |
]. |
3182 |
||
3183 |
"Created: / 29.3.1998 / 19:15:15 / cg" |
|
624 | 3184 |
"Modified: / 30.3.1998 / 17:13:47 / cg" |
622 | 3185 |
! ! |
3186 |
||
1979 | 3187 |
!ZipArchive methodsFor:'write zip'! |
3188 |
||
3189 |
addCentralZipDirectory |
|
3190 |
|zipEntry noEntries| |
|
3191 |
centralDirectory isNil ifTrue: [ |
|
3192 |
centralDirectory := ZipCentralDirectory new default. |
|
3193 |
]. |
|
3194 |
noEntries := 0. |
|
3195 |
zipEntry := firstEntry. |
|
3196 |
||
3197 |
self openFile. |
|
3198 |
file setToEnd. |
|
3199 |
centralDirectory centralDirectoryStartOffset: file position. |
|
3200 |
||
3201 |
[ zipEntry notNil ] whileTrue: [ |
|
3202 |
noEntries := noEntries + 1. |
|
3203 |
file nextPutLong: C_CENTRALHEADERSIGNATURE MSB:false. |
|
3204 |
file nextPutShort:zipEntry versionMadeBy MSB:false. |
|
3205 |
file nextPutShort:zipEntry versionNeedToExtract MSB:false. |
|
3206 |
file nextPutShort:zipEntry generalPurposBitFlag MSB:false. |
|
3207 |
file nextPutShort:zipEntry compressionMethod MSB:false. |
|
3208 |
file nextPutShort:zipEntry lastModFileTime MSB:false. |
|
3209 |
file nextPutShort:zipEntry lastModFileDate MSB:false. |
|
3210 |
file nextPutLong:zipEntry crc32 MSB:false. |
|
3211 |
file nextPutLong:zipEntry compressedSize MSB:false. |
|
3212 |
file nextPutLong:zipEntry uncompressedSize MSB:false. |
|
3213 |
file nextPutShort:zipEntry fileNameLength MSB:false. |
|
3214 |
file nextPutShort:zipEntry extraFieldLength MSB:false. |
|
3215 |
file nextPutShort:zipEntry fileCommentLength MSB:false. |
|
3216 |
file nextPutShort:zipEntry diskNumberStart MSB:false. |
|
3217 |
file nextPutShort:zipEntry internalFileAttributes MSB:false. |
|
3218 |
file nextPutLong:zipEntry externalFileAttributes MSB:false. |
|
3219 |
file nextPutLong:zipEntry relativeLocalHeaderOffset MSB:false. |
|
3220 |
||
3221 |
file nextPutAll:zipEntry fileName. |
|
3222 |
zipEntry extraField notNil ifTrue: [ |
|
3223 |
file nextPutAll:zipEntry extraField. |
|
3224 |
]. |
|
3225 |
zipEntry fileComment notNil ifTrue: [ |
|
3226 |
file nextPutAll:zipEntry fileComment. |
|
3227 |
]. |
|
3228 |
zipEntry := zipEntry next. |
|
3229 |
]. |
|
3230 |
||
3231 |
centralDirectory centralDirectoryTotalNoOfEntries: noEntries. |
|
3232 |
centralDirectory centralDirectoryTotalNoOfEntriesOnThisDisk: noEntries. |
|
3233 |
centralDirectory centralDirectorySize: (file position) - (centralDirectory centralDirectoryStartOffset). |
|
3234 |
||
3235 |
file nextPutByte:($P codePoint). |
|
3236 |
file nextPutByte:($K codePoint). |
|
3237 |
file nextPutByte:8r005. |
|
3238 |
file nextPutByte:8r006. |
|
3239 |
file nextPutShort:centralDirectory numberOfThisDisk MSB:false. |
|
3240 |
file nextPutShort:centralDirectory centralDirectoryStartDiskNumber MSB:false. |
|
3241 |
file nextPutShort:centralDirectory centralDirectoryTotalNoOfEntriesOnThisDisk MSB:false. |
|
3242 |
file nextPutShort:centralDirectory centralDirectoryTotalNoOfEntries MSB:false. |
|
3243 |
file nextPutLong:centralDirectory centralDirectorySize MSB:false. |
|
3244 |
file nextPutLong:centralDirectory centralDirectoryStartOffset MSB:false. |
|
3245 |
file nextPutShort:centralDirectory zipCommentLength MSB:false. |
|
3246 |
||
3247 |
centralDirectory zipCommentLength ~~ 0 ifTrue: [ |
|
3248 |
file nextPutAll: centralDirectory zipComment. |
|
3249 |
]. |
|
3250 |
||
3251 |
self closeFile. |
|
3252 |
! |
|
3253 |
||
3254 |
addFile: aFileName withContents: data compressMethod: theCompressMethod asDirectory: isDirectory |
|
3255 |
|zipEntry theCompressedData curTime curDate truncateZipFile| |
|
3256 |
||
3257 |
truncateZipFile := false. |
|
3258 |
zipEntry := ZipMember new default. |
|
3259 |
||
3260 |
firstEntry isNil ifTrue: [ |
|
3261 |
firstEntry := zipEntry. |
|
3262 |
truncateZipFile := true. |
|
3263 |
] ifFalse: [ |
|
3264 |
lastEntry next: zipEntry. |
|
3265 |
]. |
|
3266 |
||
3267 |
lastEntry := zipEntry. |
|
3268 |
||
3269 |
zipEntry fileName: aFileName. |
|
3270 |
zipEntry fileNameLength: aFileName size. |
|
3271 |
zipEntry uncompressedSize: data size. |
|
3272 |
||
3273 |
isDirectory ifTrue: [ |
|
3274 |
zipEntry externalFileAttributes: 16. |
|
3275 |
] ifFalse: [ |
|
3276 |
zipEntry compressionMethod: theCompressMethod. |
|
3277 |
zipEntry internalFileAttributes: 1. |
|
3278 |
zipEntry externalFileAttributes: 32. |
|
3279 |
]. |
|
3280 |
||
3281 |
curTime := Time now. |
|
3282 |
curDate := Date today. |
|
3283 |
zipEntry lastModFileTime: (((curTime seconds // 2) bitOr: (curTime minutes rightShift: -5)) bitOr: (curTime hours rightShift: -11)). |
|
3284 |
zipEntry lastModFileDate: (((curDate day) bitOr: (curDate month rightShift: -5)) bitOr: (((curDate year) - 1980) rightShift: -9)). |
|
3285 |
||
3286 |
(isDirectory not and: [theCompressMethod == 8]) ifTrue: [ |
|
3287 |
|tmpCompressedData tmpCompressedDataSize| |
|
3288 |
zipEntry crc32: (ZipStream crc32BytesIn: data). |
|
3289 |
tmpCompressedData := ByteArray new:(data size + 64). |
|
3290 |
tmpCompressedDataSize := ZipStream compress:data into:tmpCompressedData. |
|
3291 |
||
3292 |
zipEntry compressedSize: (tmpCompressedDataSize - 6 "the zlib header"). |
|
3293 |
theCompressedData := tmpCompressedData copyFrom: 3. |
|
3294 |
] ifFalse: [ |
|
3295 |
zipEntry uncompressedSize ~~ 0 ifTrue: [ |
|
3296 |
zipEntry compressedSize: zipEntry uncompressedSize - 1. |
|
3297 |
]. |
|
3298 |
theCompressedData := data asByteArray. |
|
3299 |
]. |
|
3300 |
||
3301 |
truncateZipFile ifTrue: [ |
|
3302 |
self truncateAndOpenFile. |
|
3303 |
] ifFalse: [ |
|
3304 |
self openFile. |
|
3305 |
file setToEnd. |
|
3306 |
]. |
|
3307 |
||
3308 |
zipEntry relativeLocalHeaderOffset:(file position). |
|
3309 |
file nextPutLong: 16r04034b50 MSB:false. |
|
3310 |
" file nextPutByte:($P codePoint). |
|
3311 |
file nextPutByte:($K codePoint). |
|
3312 |
file nextPutByte:8r003. |
|
3313 |
file nextPutByte:8r004. |
|
3314 |
" |
|
3315 |
file nextPutShort:zipEntry versionNeedToExtract MSB:false. |
|
3316 |
file nextPutShort:zipEntry generalPurposBitFlag MSB:false. |
|
3317 |
file nextPutShort:zipEntry compressionMethod MSB:false. |
|
3318 |
file nextPutShort:zipEntry lastModFileTime MSB:false. |
|
3319 |
file nextPutShort:zipEntry lastModFileDate MSB:false. |
|
3320 |
file nextPutLong:zipEntry crc32 MSB:false. |
|
3321 |
file nextPutLong:zipEntry compressedSize MSB:false. |
|
3322 |
file nextPutLong:zipEntry uncompressedSize MSB:false. |
|
3323 |
file nextPutShort:zipEntry fileNameLength MSB:false. |
|
3324 |
file nextPutShort:zipEntry extraFieldLength MSB:false. |
|
3325 |
file nextPutAll:zipEntry fileName. |
|
3326 |
zipEntry extraField notNil ifTrue: [ |
|
3327 |
file nextPutAll:zipEntry extraField. |
|
3328 |
]. |
|
3329 |
theCompressedData notNil ifTrue: [ |
|
3330 |
file nextPutBytes: zipEntry compressedSize from: theCompressedData. |
|
3331 |
]. |
|
3332 |
self closeFile. |
|
3333 |
! ! |
|
3334 |
||
3335 |
!ZipArchive::ZipCentralDirectory methodsFor:'accessing'! |
|
3336 |
||
3337 |
centralDirectorySize |
|
3338 |
^ centralDirectorySize |
|
3339 |
! |
|
3340 |
||
3341 |
centralDirectorySize:something |
|
3342 |
centralDirectorySize := something. |
|
3343 |
! |
|
3344 |
||
3345 |
centralDirectoryStartDiskNumber |
|
3346 |
^ centralDirectoryStartDiskNumber |
|
3347 |
! |
|
3348 |
||
3349 |
centralDirectoryStartDiskNumber:something |
|
3350 |
centralDirectoryStartDiskNumber := something. |
|
3351 |
! |
|
3352 |
||
3353 |
centralDirectoryStartOffset |
|
3354 |
^ centralDirectoryStartOffset |
|
3355 |
! |
|
3356 |
||
3357 |
centralDirectoryStartOffset:something |
|
3358 |
centralDirectoryStartOffset := something. |
|
3359 |
! |
|
3360 |
||
3361 |
centralDirectoryTotalNoOfEntries |
|
3362 |
^ centralDirectoryTotalNoOfEntries |
|
3363 |
! |
|
3364 |
||
3365 |
centralDirectoryTotalNoOfEntries:something |
|
3366 |
centralDirectoryTotalNoOfEntries := something. |
|
3367 |
! |
|
3368 |
||
3369 |
centralDirectoryTotalNoOfEntriesOnThisDisk |
|
3370 |
^ centralDirectoryTotalNoOfEntriesOnThisDisk |
|
3371 |
! |
|
3372 |
||
3373 |
centralDirectoryTotalNoOfEntriesOnThisDisk:something |
|
3374 |
centralDirectoryTotalNoOfEntriesOnThisDisk := something. |
|
3375 |
! |
|
3376 |
||
3377 |
digitalSignatureData |
|
3378 |
^ digitalSignatureData |
|
3379 |
! |
|
3380 |
||
3381 |
digitalSignatureData:something |
|
3382 |
digitalSignatureData := something. |
|
3383 |
! |
|
3384 |
||
3385 |
digitalSignatureDataSize |
|
3386 |
^ digitalSignatureDataSize |
|
3387 |
! |
|
3388 |
||
3389 |
digitalSignatureDataSize:something |
|
3390 |
digitalSignatureDataSize := something. |
|
3391 |
! |
|
3392 |
||
3393 |
numberOfThisDisk |
|
3394 |
^ numberOfThisDisk |
|
3395 |
! |
|
3396 |
||
3397 |
numberOfThisDisk:something |
|
3398 |
numberOfThisDisk := something. |
|
3399 |
! |
|
3400 |
||
3401 |
zipComment |
|
3402 |
^ zipComment |
|
3403 |
! |
|
3404 |
||
3405 |
zipComment:something |
|
3406 |
zipComment := something. |
|
3407 |
! |
|
3408 |
||
3409 |
zipCommentLength |
|
3410 |
^ zipCommentLength |
|
3411 |
! |
|
3412 |
||
3413 |
zipCommentLength:something |
|
3414 |
zipCommentLength := something. |
|
3415 |
! ! |
|
3416 |
||
3417 |
!ZipArchive::ZipCentralDirectory methodsFor:'initialize'! |
|
3418 |
||
3419 |
default |
|
3420 |
numberOfThisDisk := 0. |
|
3421 |
centralDirectoryStartDiskNumber := 0. |
|
3422 |
centralDirectoryTotalNoOfEntriesOnThisDisk := 0. |
|
3423 |
centralDirectoryTotalNoOfEntries := 0. |
|
3424 |
centralDirectorySize := 0. |
|
3425 |
centralDirectoryStartOffset := 0. |
|
3426 |
zipCommentLength := 0. |
|
3427 |
zipComment := nil. |
|
3428 |
digitalSignatureDataSize := 0. |
|
3429 |
digitalSignatureData := nil. |
|
3430 |
! ! |
|
3431 |
||
651 | 3432 |
!ZipArchive::ZipMember class methodsFor:'documentation'! |
3433 |
||
3434 |
documentation |
|
3435 |
" |
|
3436 |
keeps some information for a single entry in a zipFile. |
|
3437 |
" |
|
3438 |
||
3439 |
||
3440 |
! ! |
|
3441 |
||
622 | 3442 |
!ZipArchive::ZipMember methodsFor:'accessing'! |
3443 |
||
1979 | 3444 |
compressedSize |
3445 |
^ compressedSize |
|
622 | 3446 |
! |
3447 |
||
1979 | 3448 |
compressedSize:something |
3449 |
compressedSize := something. |
|
622 | 3450 |
! |
3451 |
||
1979 | 3452 |
compressionMethod |
3453 |
^ compressionMethod |
|
622 | 3454 |
! |
3455 |
||
1979 | 3456 |
compressionMethod:something |
3457 |
compressionMethod := something. |
|
622 | 3458 |
! |
3459 |
||
3460 |
crc32 |
|
3461 |
"return the value of the instance variable 'crc32' (automatically generated)" |
|
3462 |
||
3463 |
^ crc32 |
|
3464 |
||
3465 |
"Created: / 29.3.1998 / 20:03:00 / cg" |
|
3466 |
! |
|
3467 |
||
3468 |
crc32:something |
|
3469 |
"set the value of the instance variable 'crc32' (automatically generated)" |
|
3470 |
||
3471 |
crc32 := something. |
|
3472 |
||
3473 |
"Created: / 29.3.1998 / 20:03:00 / cg" |
|
3474 |
! |
|
3475 |
||
638
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3476 |
data |
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3477 |
"return the value of the instance variable 'data' (automatically generated)" |
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3478 |
|
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3479 |
^ data |
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3480 |
|
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3481 |
"Created: / 9.4.1998 / 13:05:03 / cg" |
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3482 |
! |
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3483 |
|
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3484 |
data:something |
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3485 |
"set the value of the instance variable 'data' (automatically generated)" |
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3486 |
|
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3487 |
data := something. |
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3488 |
|
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3489 |
"Created: / 9.4.1998 / 13:05:03 / cg" |
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3490 |
! |
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3491 |
|
938
4544b3c105fe
fixed directory reading (care for comment and extra-header bytes)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
3492 |
dataStart |
4544b3c105fe
fixed directory reading (care for comment and extra-header bytes)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
3493 |
"return the value of the instance variable 'dataStart' (automatically generated)" |
4544b3c105fe
fixed directory reading (care for comment and extra-header bytes)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
3494 |
|
1979 | 3495 |
dataStart isNil ifTrue: [ |
3496 |
dataStart := relativeLocalHeaderOffset |
|
3497 |
+ "C_SIZEOFLOCALHEADER" 30 |
|
3498 |
+ fileNameLength |
|
3499 |
+ extraFieldLength. |
|
3500 |
]. |
|
938
4544b3c105fe
fixed directory reading (care for comment and extra-header bytes)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
3501 |
^ dataStart |
4544b3c105fe
fixed directory reading (care for comment and extra-header bytes)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
3502 |
"Created: / 29.3.1998 / 18:28:40 / cg" |
4544b3c105fe
fixed directory reading (care for comment and extra-header bytes)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
3503 |
! |
4544b3c105fe
fixed directory reading (care for comment and extra-header bytes)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
3504 |
|
4544b3c105fe
fixed directory reading (care for comment and extra-header bytes)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
3505 |
dataStart:something |
4544b3c105fe
fixed directory reading (care for comment and extra-header bytes)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
3506 |
"set the value of the instance variable 'dataStart' (automatically generated)" |
4544b3c105fe
fixed directory reading (care for comment and extra-header bytes)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
3507 |
|
4544b3c105fe
fixed directory reading (care for comment and extra-header bytes)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
3508 |
dataStart := something. |
4544b3c105fe
fixed directory reading (care for comment and extra-header bytes)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
3509 |
|
4544b3c105fe
fixed directory reading (care for comment and extra-header bytes)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
3510 |
"Created: / 29.3.1998 / 18:28:40 / cg" |
4544b3c105fe
fixed directory reading (care for comment and extra-header bytes)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
3511 |
! |
4544b3c105fe
fixed directory reading (care for comment and extra-header bytes)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
3512 |
|
1979 | 3513 |
diskNumberStart |
3514 |
^ diskNumberStart |
|
3515 |
! |
|
3516 |
||
3517 |
diskNumberStart:something |
|
3518 |
diskNumberStart := something. |
|
3519 |
! |
|
3520 |
||
3521 |
externalFileAttributes |
|
3522 |
^ externalFileAttributes |
|
3523 |
! |
|
3524 |
||
3525 |
externalFileAttributes:something |
|
3526 |
externalFileAttributes := something. |
|
3527 |
! |
|
3528 |
||
3529 |
extraField |
|
3530 |
^ extraField |
|
3531 |
! |
|
3532 |
||
3533 |
extraField:something |
|
3534 |
extraField := something. |
|
3535 |
! |
|
3536 |
||
3537 |
extraFieldLength |
|
3538 |
^ extraFieldLength |
|
3539 |
! |
|
3540 |
||
3541 |
extraFieldLength:something |
|
3542 |
extraFieldLength := something. |
|
3543 |
! |
|
3544 |
||
3545 |
fileComment |
|
3546 |
^ fileComment |
|
3547 |
! |
|
3548 |
||
3549 |
fileComment:something |
|
3550 |
fileComment := something. |
|
3551 |
! |
|
3552 |
||
3553 |
fileCommentLength |
|
3554 |
^ fileCommentLength |
|
3555 |
! |
|
3556 |
||
3557 |
fileCommentLength:something |
|
3558 |
fileCommentLength := something. |
|
622 | 3559 |
! |
3560 |
||
1979 | 3561 |
fileName |
3562 |
^ fileName |
|
3563 |
! |
|
3564 |
||
3565 |
fileName:something |
|
3566 |
fileName := something. |
|
3567 |
! |
|
3568 |
||
3569 |
fileNameLength |
|
3570 |
^ fileNameLength |
|
3571 |
! |
|
3572 |
||
3573 |
fileNameLength:something |
|
3574 |
fileNameLength := something. |
|
3575 |
! |
|
3576 |
||
3577 |
generalPurposBitFlag |
|
3578 |
^ generalPurposBitFlag |
|
3579 |
! |
|
3580 |
||
3581 |
generalPurposBitFlag:something |
|
3582 |
generalPurposBitFlag := something. |
|
3583 |
! |
|
3584 |
||
3585 |
internalFileAttributes |
|
3586 |
^ internalFileAttributes |
|
3587 |
! |
|
3588 |
||
3589 |
internalFileAttributes:something |
|
3590 |
internalFileAttributes := something. |
|
3591 |
! |
|
3592 |
||
3593 |
lastModFileDate |
|
3594 |
^ lastModFileDate |
|
3595 |
! |
|
3596 |
||
3597 |
lastModFileDate:something |
|
3598 |
lastModFileDate := something. |
|
3599 |
! |
|
3600 |
||
3601 |
lastModFileTime |
|
3602 |
^ lastModFileTime |
|
3603 |
! |
|
3604 |
||
3605 |
lastModFileTime:something |
|
3606 |
lastModFileTime := something. |
|
622 | 3607 |
! |
3608 |
||
3609 |
next |
|
3610 |
"return the value of the instance variable 'next' (automatically generated)" |
|
3611 |
||
3612 |
^ next |
|
3613 |
||
3614 |
"Created: / 29.3.1998 / 18:29:42 / cg" |
|
3615 |
! |
|
3616 |
||
3617 |
next:something |
|
3618 |
"set the value of the instance variable 'next' (automatically generated)" |
|
3619 |
||
3620 |
next := something. |
|
3621 |
||
3622 |
"Created: / 29.3.1998 / 18:29:42 / cg" |
|
3623 |
! |
|
3624 |
||
1979 | 3625 |
relativeLocalHeaderOffset |
3626 |
^ relativeLocalHeaderOffset |
|
3627 |
! |
|
3628 |
||
3629 |
relativeLocalHeaderOffset:something |
|
3630 |
relativeLocalHeaderOffset := something. |
|
3631 |
! |
|
3632 |
||
3633 |
uncompressedSize |
|
3634 |
^ uncompressedSize |
|
3635 |
! |
|
3636 |
||
3637 |
uncompressedSize:something |
|
3638 |
uncompressedSize := something. |
|
3639 |
! |
|
3640 |
||
3641 |
versionMadeBy |
|
3642 |
^ versionMadeBy |
|
3643 |
! |
|
3644 |
||
3645 |
versionMadeBy:something |
|
3646 |
versionMadeBy := something. |
|
3647 |
! |
|
3648 |
||
3649 |
versionNeedToExtract |
|
3650 |
^ versionNeedToExtract |
|
622 | 3651 |
! |
3652 |
||
1979 | 3653 |
versionNeedToExtract:something |
3654 |
versionNeedToExtract := something. |
|
3655 |
! ! |
|
3656 |
||
3657 |
!ZipArchive::ZipMember methodsFor:'initialize'! |
|
3658 |
||
3659 |
default |
|
3660 |
versionMadeBy := 20. |
|
3661 |
versionNeedToExtract := 20. |
|
3662 |
generalPurposBitFlag := 0. |
|
3663 |
compressionMethod := 0. |
|
3664 |
lastModFileTime := 0. |
|
3665 |
lastModFileDate := 0. |
|
3666 |
crc32 := 0. |
|
3667 |
compressedSize := 0. |
|
3668 |
uncompressedSize := 0. |
|
3669 |
fileNameLength := 0. |
|
3670 |
extraFieldLength := 0. |
|
3671 |
fileCommentLength := 0. |
|
3672 |
diskNumberStart := 0. |
|
3673 |
internalFileAttributes := 0. |
|
3674 |
externalFileAttributes := 0. |
|
3675 |
relativeLocalHeaderOffset := 0. |
|
3676 |
fileName := nil. |
|
3677 |
extraField := nil. |
|
3678 |
fileComment := nil. |
|
3679 |
dataStart := 0. |
|
3680 |
data := nil. |
|
622 | 3681 |
! ! |
3682 |
||
3683 |
!ZipArchive::ZipMember methodsFor:'printing & storing'! |
|
3684 |
||
3685 |
displayString |
|
1979 | 3686 |
^ 'ZipMember(' , (fileName ? '*nil*') , ')' |
622 | 3687 |
|
3688 |
"Created: / 29.3.1998 / 20:10:07 / cg" |
|
634 | 3689 |
"Modified: / 2.4.1998 / 15:10:08 / cg" |
622 | 3690 |
! ! |
3691 |
||
3692 |
!ZipArchive::ZipMember methodsFor:'queries'! |
|
3693 |
||
3694 |
fileStart |
|
1979 | 3695 |
^ self dataStart |
938
4544b3c105fe
fixed directory reading (care for comment and extra-header bytes)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
3696 |
"/ ^ relative_offset_local_header + ZipArchive LREC_SIZE + 4 + name size |
622 | 3697 |
|
3698 |
"Created: / 29.3.1998 / 19:10:57 / cg" |
|
3699 |
! ! |
|
3700 |
||
628
27102a6bd3f7
remember recently visited zipArchives for faster access
Claus Gittinger <cg@exept.de>
parents:
625
diff
changeset
|
3701 |
!ZipArchive class methodsFor:'documentation'! |
27102a6bd3f7
remember recently visited zipArchives for faster access
Claus Gittinger <cg@exept.de>
parents:
625
diff
changeset
|
3702 |
|
27102a6bd3f7
remember recently visited zipArchives for faster access
Claus Gittinger <cg@exept.de>
parents:
625
diff
changeset
|
3703 |
version |
1979 | 3704 |
^ '$Header: /cvs/stx/stx/libbasic2/ZipArchive.st,v 1.52 2008-04-24 15:38:08 ab Exp $' |
628
27102a6bd3f7
remember recently visited zipArchives for faster access
Claus Gittinger <cg@exept.de>
parents:
625
diff
changeset
|
3705 |
! ! |
1129
8e0da7fb22fb
Use #raiseErrorString: instead of #raiseWith:
Stefan Vogel <sv@exept.de>
parents:
970
diff
changeset
|
3706 |
|
622 | 3707 |
ZipArchive initialize! |