author | Claus Gittinger <cg@exept.de> |
Thu, 06 Sep 2007 17:31:09 +0200 | |
changeset 1894 | 8bf137acc445 |
parent 1839 | c10cd58ec334 |
child 1979 | 6eff3f1f1b80 |
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 |
16 |
recentlyExtractedEntries' |
|
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 |
||
29 |
Object subclass:#ZipMember |
|
970 | 30 |
instanceVariableNames:'next dataStart compressed_size uncompressed_size name crc32 |
31 |
compression_method data' |
|
32 |
classVariableNames:'' |
|
33 |
poolDictionaries:'' |
|
34 |
privateIn:ZipArchive |
|
622 | 35 |
! |
36 |
||
636 | 37 |
!ZipArchive primitiveDefinitions! |
38 |
%{ |
|
39 |
||
720 | 40 |
|
636 | 41 |
#include <stdio.h> |
42 |
||
43 |
#define uchar unsigned char |
|
44 |
#define ushort unsigned short |
|
45 |
#define ulong unsigned long |
|
46 |
||
47 |
/* |
|
48 |
* inflate definitions |
|
49 |
*/ |
|
50 |
#define PKZIP_BUG_WORKAROUND /* PKZIP 1.93a problem--live with it */ |
|
51 |
#ifndef WSIZE /* default is 32K */ |
|
52 |
# define WSIZE 0x8000 /* window size--must be a power of two, and at least */ |
|
53 |
#endif /* 32K for zip's deflate method */ |
|
54 |
||
55 |
#define NEXTBYTE (*inPtr++) |
|
637 | 56 |
#define XXXFLUSH(n) slide += (n) |
723 | 57 |
#define FLUSH(n) { bcopy(slide, outPtr, (n)); outPtr += (n); } |
58 |
||
59 |
#ifdef DEBUG |
|
1839 | 60 |
# define Trace(x) if (debugTrace) { console_fprintf x ; } |
636 | 61 |
#else |
62 |
# define Trace(x) /* nothing */ |
|
63 |
#endif |
|
64 |
||
65 |
/* Huffman code lookup table entry--this entry is four bytes for machines |
|
66 |
that have 16-bit pointers (e.g. PC's in the small or medium model). |
|
67 |
Valid extra bits are 0..13. e == 15 is EOB (end of block), e == 16 |
|
68 |
means that v is a literal, 16 < e < 32 means that v is a pointer to |
|
69 |
the next table, which codes e - 16 bits, and lastly e == 99 indicates |
|
70 |
an unused code. If a code with e == 99 is looked up, this implies an |
|
71 |
error in the data. */ |
|
72 |
struct huft { |
|
73 |
uchar e; /* number of extra bits or operation */ |
|
74 |
uchar b; /* number of bits in this code or subcode */ |
|
75 |
union { |
|
76 |
ushort n; /* literal, length base, or distance base */ |
|
77 |
struct huft *t; /* pointer to next level of table */ |
|
78 |
} v; |
|
79 |
}; |
|
80 |
||
81 |
%} |
|
82 |
! ! |
|
83 |
||
84 |
!ZipArchive primitiveVariables! |
|
85 |
%{ |
|
86 |
||
723 | 87 |
static int debugTrace = 0; |
88 |
||
636 | 89 |
/* |
90 |
* inflate variables |
|
91 |
*/ |
|
92 |
||
93 |
static unsigned char *inPtr; |
|
94 |
static unsigned char *outPtr; |
|
95 |
static unsigned char *slide; |
|
96 |
||
97 |
static int qflag = 0; |
|
98 |
||
99 |
/* The inflate algorithm uses a sliding 32K byte window on the uncompressed |
|
100 |
stream to find repeated byte strings. This is implemented here as a |
|
101 |
circular buffer. The index is updated simply by incrementing and then |
|
102 |
and'ing with 0x7fff (32K-1). */ |
|
103 |
/* It is left to other modules to supply the 32K area. It is assumed |
|
104 |
to be usable as if it were declared "uchar slide[32768];" or as just |
|
105 |
"uchar *slide;" and then malloc'ed in the latter case. The definition |
|
106 |
must be in unzip.h, included above. */ |
|
107 |
static unsigned wp; /* current position in slide */ |
|
108 |
||
109 |
||
110 |
/* Tables for deflate from PKZIP's appnote.txt. */ |
|
111 |
static unsigned border[] = { /* Order of the bit length code lengths */ |
|
1839 | 112 |
16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; |
636 | 113 |
|
114 |
static ushort cplens[] = { /* Copy lengths for literal codes 257..285 */ |
|
1839 | 115 |
3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, |
116 |
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; |
|
117 |
/* note: see note #13 above about the 258 in this list. */ |
|
636 | 118 |
|
119 |
static ushort cplext[] = { /* Extra bits for literal codes 257..285 */ |
|
1839 | 120 |
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, |
121 |
3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 99, 99}; /* 99==invalid */ |
|
636 | 122 |
|
123 |
static ushort cpdist[] = { /* Copy offsets for distance codes 0..29 */ |
|
1839 | 124 |
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, |
125 |
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, |
|
126 |
8193, 12289, 16385, 24577}; |
|
636 | 127 |
static ushort cpdext[] = { /* Extra bits for distance codes */ |
1839 | 128 |
0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, |
129 |
7, 7, 8, 8, 9, 9, 10, 10, 11, 11, |
|
130 |
12, 12, 13, 13}; |
|
636 | 131 |
|
132 |
/* And'ing with mask[n] masks the lower n bits */ |
|
133 |
static ushort mask[] = { |
|
134 |
0x0000, |
|
135 |
0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff, |
|
136 |
0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff |
|
137 |
}; |
|
138 |
||
139 |
||
140 |
/* Macros for inflate() bit peeking and grabbing. |
|
141 |
The usage is: |
|
142 |
||
1839 | 143 |
NEEDBITS(j) |
144 |
x = b & mask[j]; |
|
145 |
DUMPBITS(j) |
|
636 | 146 |
|
147 |
where NEEDBITS makes sure that b has at least j bits in it, and |
|
148 |
DUMPBITS removes the bits from b. The macros use the variable k |
|
149 |
for the number of bits in b. Normally, b and k are register |
|
150 |
variables for speed, and are initialized at the begining of a |
|
151 |
routine that uses these macros from a global bit buffer and count. |
|
152 |
||
153 |
In order to not ask for more bits than there are in the compressed |
|
154 |
stream, the Huffman tables are constructed to only ask for just |
|
155 |
enough bits to make up the end-of-block code (value 256). Then no |
|
156 |
bytes need to be "returned" to the buffer at the end of the last |
|
157 |
block. See the huft_build() routine. |
|
158 |
*/ |
|
159 |
||
160 |
static ulong bb; /* bit buffer */ |
|
161 |
static unsigned bk; /* bits in bit buffer */ |
|
162 |
||
637 | 163 |
#define NEEDBITS(n) { while(k<(n)){ b |= ((ulong)NEXTBYTE)<<k; k+=8; } } |
164 |
#define DUMPBITS(n) { b>>=(n); k-=(n); } |
|
636 | 165 |
|
166 |
||
167 |
/* |
|
168 |
Huffman code decoding is performed using a multi-level table lookup. |
|
169 |
The fastest way to decode is to simply build a lookup table whose |
|
170 |
size is determined by the longest code. However, the time it takes |
|
171 |
to build this table can also be a factor if the data being decoded |
|
172 |
is not very long. The most common codes are necessarily the |
|
173 |
shortest codes, so those codes dominate the decoding time, and hence |
|
174 |
the speed. The idea is you can have a shorter table that decodes the |
|
175 |
shorter, more probable codes, and then point to subsidiary tables for |
|
176 |
the longer codes. The time it costs to decode the longer codes is |
|
177 |
then traded against the time it takes to make longer tables. |
|
178 |
||
179 |
This results of this trade are in the variables lbits and dbits |
|
180 |
below. lbits is the number of bits the first level table for literal/ |
|
181 |
length codes can decode in one step, and dbits is the same thing for |
|
182 |
the distance codes. Subsequent tables are also less than or equal to |
|
183 |
those sizes. These values may be adjusted either when all of the |
|
184 |
codes are shorter than that, in which case the longest code length in |
|
185 |
bits is used, or when the shortest code is *longer* than the requested |
|
186 |
table size, in which case the length of the shortest code in bits is |
|
187 |
used. |
|
188 |
||
189 |
There are two different values for the two tables, since they code a |
|
190 |
different number of possibilities each. The literal/length table |
|
191 |
codes 286 possible values, or in a flat code, a little over eight |
|
192 |
bits. The distance table codes 30 possible values, or a little less |
|
193 |
than five bits, flat. The optimum values for speed end up being |
|
194 |
about one bit more than those, so lbits is 8+1 and dbits is 5+1. |
|
195 |
The optimum values may differ though from machine to machine, and |
|
196 |
possibly even between compilers. Your mileage may vary. |
|
197 |
*/ |
|
198 |
||
199 |
||
200 |
static int lbits = 9; /* bits in base literal/length lookup table */ |
|
201 |
static int dbits = 6; /* bits in base distance lookup table */ |
|
202 |
||
203 |
||
204 |
/* If BMAX needs to be larger than 16, then h and x[] should be ulong. */ |
|
205 |
#define BMAX 16 /* maximum bit length of any code (16 for explode) */ |
|
206 |
#define N_MAX 288 /* maximum number of codes in any set */ |
|
207 |
||
208 |
||
209 |
static unsigned hufts; /* track memory usage */ |
|
210 |
||
211 |
%} |
|
212 |
! ! |
|
213 |
||
214 |
!ZipArchive primitiveFunctions! |
|
215 |
%{ |
|
216 |
||
217 |
/* |
|
218 |
* inflate algorithm |
|
219 |
*/ |
|
220 |
||
221 |
/* Free the malloc'ed tables built by huft_build(), which makes a linked |
|
222 |
list of the tables it made, with the links in a dummy first entry of |
|
223 |
each table. */ |
|
1839 | 224 |
static int |
636 | 225 |
huft_free(t) |
226 |
struct huft *t; /* table to free */ |
|
227 |
{ |
|
228 |
register struct huft *p, *q; |
|
229 |
||
230 |
||
231 |
/* Go through linked list, freeing from the malloced (t[-1]) address. */ |
|
232 |
p = t; |
|
233 |
while (p != (struct huft *)NULL) |
|
234 |
{ |
|
235 |
q = (--p)->v.t; |
|
236 |
free(p); |
|
237 |
p = q; |
|
1839 | 238 |
} |
636 | 239 |
return 0; |
240 |
} |
|
241 |
||
242 |
||
243 |
||
244 |
||
245 |
/* Given a list of code lengths and a maximum table size, make a set of |
|
246 |
tables to decode that set of codes. Return zero on success, one if |
|
247 |
the given code set is incomplete (the tables are still built in this |
|
248 |
case), two if the input is invalid (all zero length codes or an |
|
249 |
oversubscribed set of lengths), and three if not enough memory. |
|
250 |
The code with value 256 is special, and the tables are constructed |
|
251 |
so that no bits beyond that code are fetched when that code is |
|
252 |
decoded. */ |
|
1839 | 253 |
static int |
636 | 254 |
huft_build(b, n, s, d, e, t, m) |
255 |
unsigned *b; /* code lengths in bits (all assumed <= BMAX) */ |
|
256 |
unsigned n; /* number of codes (assumed <= N_MAX) */ |
|
257 |
unsigned s; /* number of simple-valued codes (0..s-1) */ |
|
258 |
ushort *d; /* list of base values for non-simple codes */ |
|
259 |
ushort *e; /* list of extra bits for non-simple codes */ |
|
260 |
struct huft **t; /* result: starting table */ |
|
261 |
int *m; /* maximum lookup bits, returns actual */ |
|
262 |
{ |
|
263 |
unsigned a; /* counter for codes of length k */ |
|
264 |
unsigned c[BMAX+1]; /* bit length count table */ |
|
265 |
unsigned el; /* length of EOB code (value 256) */ |
|
266 |
unsigned f; /* i repeats in table every f entries */ |
|
267 |
int g; /* maximum code length */ |
|
268 |
int h; /* table level */ |
|
269 |
register unsigned i; /* counter, current code */ |
|
270 |
register unsigned j; /* counter */ |
|
271 |
register int k; /* number of bits in current code */ |
|
272 |
int lx[BMAX+1]; /* memory for l[-1..BMAX-1] */ |
|
273 |
int *l = lx+1; /* stack of bits per table */ |
|
274 |
register unsigned *p; /* pointer into c[], b[], or v[] */ |
|
275 |
register struct huft *q; /* points to current table */ |
|
276 |
struct huft r; /* table entry for structure assignment */ |
|
277 |
struct huft *u[BMAX]; /* table stack */ |
|
278 |
static unsigned v[N_MAX]; /* values in order of bit length */ |
|
279 |
register int w; /* bits before this table == (l * h) */ |
|
280 |
unsigned x[BMAX+1]; /* bit offsets, then code stack */ |
|
281 |
unsigned *xp; /* pointer into x */ |
|
282 |
int y; /* number of dummy codes added */ |
|
283 |
unsigned z; /* number of entries in current table */ |
|
1749 | 284 |
extern void *malloc(); |
636 | 285 |
|
286 |
/* Generate counts for each bit length */ |
|
287 |
el = n > 256 ? b[256] : BMAX; /* set length of EOB code, if any */ |
|
288 |
bzero((char *)c, sizeof(c)); |
|
289 |
p = b; i = n; |
|
290 |
do { |
|
291 |
c[*p]++; p++; /* assume all entries <= BMAX */ |
|
292 |
} while (--i); |
|
293 |
if (c[0] == n) /* null input--all zero length codes */ |
|
294 |
{ |
|
295 |
*t = (struct huft *)NULL; |
|
296 |
*m = 0; |
|
297 |
return 0; |
|
298 |
} |
|
299 |
||
300 |
||
301 |
/* Find minimum and maximum length, bound *m by those */ |
|
302 |
for (j = 1; j <= BMAX; j++) |
|
303 |
if (c[j]) |
|
304 |
break; |
|
305 |
k = j; /* minimum code length */ |
|
306 |
if ((unsigned)*m < j) |
|
307 |
*m = j; |
|
308 |
for (i = BMAX; i; i--) |
|
309 |
if (c[i]) |
|
310 |
break; |
|
311 |
g = i; /* maximum code length */ |
|
312 |
if ((unsigned)*m > i) |
|
313 |
*m = i; |
|
314 |
||
315 |
||
316 |
/* Adjust last length count to fill out codes, if needed */ |
|
317 |
for (y = 1 << j; j < i; j++, y <<= 1) |
|
318 |
if ((y -= c[j]) < 0) |
|
319 |
return 2; /* bad input: more codes than bits */ |
|
320 |
if ((y -= c[i]) < 0) |
|
321 |
return 2; |
|
322 |
c[i] += y; |
|
323 |
||
324 |
||
325 |
/* Generate starting offsets into the value table for each length */ |
|
326 |
x[1] = j = 0; |
|
327 |
p = c + 1; xp = x + 2; |
|
328 |
while (--i) { /* note that i == g from above */ |
|
329 |
*xp++ = (j += *p++); |
|
330 |
} |
|
331 |
||
332 |
||
333 |
/* Make a table of values in order of bit lengths */ |
|
334 |
p = b; i = 0; |
|
335 |
do { |
|
336 |
if ((j = *p++) != 0) |
|
337 |
v[x[j]++] = i; |
|
338 |
} while (++i < n); |
|
339 |
||
340 |
||
341 |
/* Generate the Huffman codes and for each, make the table entries */ |
|
342 |
x[0] = i = 0; /* first Huffman code is zero */ |
|
343 |
p = v; /* grab values in bit order */ |
|
344 |
h = -1; /* no tables yet--level -1 */ |
|
345 |
w = l[-1] = 0; /* no bits decoded yet */ |
|
346 |
u[0] = (struct huft *)NULL; /* just to keep compilers happy */ |
|
347 |
q = (struct huft *)NULL; /* ditto */ |
|
348 |
z = 0; /* ditto */ |
|
349 |
||
350 |
/* go through the bit lengths (k already is bits in shortest code) */ |
|
351 |
for (; k <= g; k++) |
|
352 |
{ |
|
353 |
a = c[k]; |
|
354 |
while (a--) |
|
355 |
{ |
|
356 |
/* here i is the Huffman code of length k bits for value *p */ |
|
357 |
/* make tables up to required level */ |
|
358 |
while (k > w + l[h]) |
|
359 |
{ |
|
1839 | 360 |
w += l[h++]; /* add bits already decoded */ |
636 | 361 |
|
1839 | 362 |
/* compute minimum size table less than or equal to *m bits */ |
363 |
z = (z = g - w) > (unsigned)*m ? *m : z; /* upper limit */ |
|
364 |
if ((f = 1 << (j = k - w)) > a + 1) /* try a k-w bit table */ |
|
365 |
{ /* too few codes for k-w bit table */ |
|
366 |
f -= a + 1; /* deduct codes from patterns left */ |
|
367 |
xp = c + k; |
|
368 |
while (++j < z) /* try smaller tables up to z bits */ |
|
369 |
{ |
|
370 |
if ((f <<= 1) <= *++xp) |
|
371 |
break; /* enough codes to use up j bits */ |
|
372 |
f -= *xp; /* else deduct codes from patterns */ |
|
373 |
} |
|
374 |
} |
|
375 |
if ((unsigned)w + j > el && (unsigned)w < el) |
|
376 |
j = el - w; /* make EOB code end at table */ |
|
377 |
z = 1 << j; /* table entries for j-bit table */ |
|
378 |
l[h] = j; /* set table size in stack */ |
|
636 | 379 |
|
1839 | 380 |
/* allocate and link in new table */ |
381 |
if ((q = (struct huft *)malloc((z + 1)*sizeof(struct huft))) == |
|
382 |
(struct huft *)NULL) |
|
383 |
{ |
|
384 |
if (h) |
|
385 |
huft_free(u[0]); |
|
386 |
return 3; /* not enough memory */ |
|
387 |
} |
|
388 |
hufts += z + 1; /* track memory usage */ |
|
389 |
*t = q + 1; /* link to list for huft_free() */ |
|
390 |
*(t = &(q->v.t)) = (struct huft *)NULL; |
|
391 |
u[h] = ++q; /* table starts after link */ |
|
636 | 392 |
|
1839 | 393 |
/* connect to last table, if there is one */ |
394 |
if (h) |
|
395 |
{ |
|
396 |
x[h] = i; /* save pattern for backing up */ |
|
397 |
r.b = (uchar)l[h-1]; /* bits to dump before this table */ |
|
398 |
r.e = (uchar)(16 + j); /* bits in this table */ |
|
399 |
r.v.t = q; /* pointer to this table */ |
|
400 |
j = (i & ((1 << w) - 1)) >> (w - l[h-1]); |
|
401 |
u[h-1][j] = r; /* connect to last table */ |
|
402 |
} |
|
636 | 403 |
} |
404 |
||
405 |
/* set up table entry in r */ |
|
406 |
r.b = (uchar)(k - w); |
|
407 |
if (p >= v + n) |
|
1839 | 408 |
r.e = 99; /* out of values--invalid code */ |
636 | 409 |
else if (*p < s) |
410 |
{ |
|
1839 | 411 |
r.e = (uchar)(*p < 256 ? 16 : 15); /* 256 is end-of-block code */ |
412 |
r.v.n = *p++; /* simple code is just the value */ |
|
636 | 413 |
} |
414 |
else |
|
415 |
{ |
|
1839 | 416 |
r.e = (uchar)e[*p - s]; /* non-simple--look up in lists */ |
417 |
r.v.n = d[*p++ - s]; |
|
636 | 418 |
} |
419 |
||
420 |
/* fill code-like entries with r */ |
|
421 |
f = 1 << (k - w); |
|
422 |
for (j = i >> w; j < z; j += f) |
|
1839 | 423 |
q[j] = r; |
636 | 424 |
|
425 |
/* backwards increment the k-bit code i */ |
|
426 |
for (j = 1 << (k - 1); i & j; j >>= 1) |
|
1839 | 427 |
i ^= j; |
636 | 428 |
i ^= j; |
429 |
||
430 |
/* backup over finished tables */ |
|
431 |
while ((i & ((1 << w) - 1)) != x[h]) |
|
1839 | 432 |
w -= l[--h]; /* don't need to update q */ |
636 | 433 |
} |
434 |
} |
|
435 |
||
436 |
||
437 |
/* return actual size of base table */ |
|
438 |
*m = l[0]; |
|
439 |
||
440 |
||
441 |
/* Return true (1) if we were given an incomplete table */ |
|
442 |
return y != 0 && g != 1; |
|
443 |
} |
|
444 |
||
445 |
||
446 |
||
447 |
#ifdef ASM_INFLATECODES |
|
448 |
# define inflate_codes(tl,td,bl,bd) flate_codes(tl,td,bl,bd,(uchar *)slide) |
|
449 |
int flate_codes OF((struct huft *, struct huft *, int, int, uchar *)); |
|
450 |
||
451 |
#else |
|
452 |
||
453 |
/* inflate (decompress) the codes in a deflated (compressed) block. |
|
454 |
Return an error code or zero if it all goes ok. */ |
|
1839 | 455 |
static int |
636 | 456 |
inflate_codes(tl, td, bl, bd) |
457 |
struct huft *tl, *td; /* literal/length and distance decoder tables */ |
|
458 |
int bl, bd; /* number of bits decoded by tl[] and td[] */ |
|
459 |
{ |
|
460 |
register unsigned e; /* table entry flag/number of extra bits */ |
|
461 |
unsigned n, d; /* length and index for copy */ |
|
462 |
unsigned w; /* current window position */ |
|
463 |
struct huft *t; /* pointer to table entry */ |
|
464 |
unsigned ml, md; /* masks for bl and bd bits */ |
|
465 |
register ulong b; /* bit buffer */ |
|
466 |
register unsigned k; /* number of bits in bit buffer */ |
|
467 |
||
468 |
||
469 |
/* make local copies of globals */ |
|
470 |
b = bb; /* initialize bit buffer */ |
|
471 |
k = bk; |
|
472 |
w = wp; /* initialize window position */ |
|
473 |
||
474 |
||
475 |
/* inflate the coded data */ |
|
476 |
ml = mask[bl]; /* precompute masks for speed */ |
|
477 |
md = mask[bd]; |
|
478 |
while (1) /* do until end of block */ |
|
479 |
{ |
|
480 |
NEEDBITS((unsigned)bl) |
|
481 |
if ((e = (t = tl + ((unsigned)b & ml))->e) > 16) |
|
482 |
do { |
|
1839 | 483 |
if (e == 99) |
484 |
return 1; |
|
485 |
DUMPBITS(t->b) |
|
486 |
e -= 16; |
|
487 |
NEEDBITS(e) |
|
636 | 488 |
} while ((e = (t = t->v.t + ((unsigned)b & mask[e]))->e) > 16); |
489 |
DUMPBITS(t->b) |
|
490 |
if (e == 16) /* then it's a literal */ |
|
491 |
{ |
|
492 |
slide[w++] = (uchar)t->v.n; |
|
493 |
if (w == WSIZE) |
|
494 |
{ |
|
1839 | 495 |
FLUSH(w); |
496 |
w = 0; |
|
636 | 497 |
} |
498 |
} |
|
499 |
else /* it's an EOB or a length */ |
|
500 |
{ |
|
501 |
/* exit if end of block */ |
|
502 |
if (e == 15) |
|
1839 | 503 |
break; |
636 | 504 |
|
505 |
/* get length of block to copy */ |
|
506 |
NEEDBITS(e) |
|
507 |
n = t->v.n + ((unsigned)b & mask[e]); |
|
508 |
DUMPBITS(e); |
|
509 |
||
510 |
/* decode distance of block to copy */ |
|
511 |
NEEDBITS((unsigned)bd) |
|
512 |
if ((e = (t = td + ((unsigned)b & md))->e) > 16) |
|
1839 | 513 |
do { |
514 |
if (e == 99) |
|
515 |
return 1; |
|
516 |
DUMPBITS(t->b) |
|
517 |
e -= 16; |
|
518 |
NEEDBITS(e) |
|
519 |
} while ((e = (t = t->v.t + ((unsigned)b & mask[e]))->e) > 16); |
|
636 | 520 |
DUMPBITS(t->b) |
521 |
NEEDBITS(e) |
|
522 |
d = w - t->v.n - ((unsigned)b & mask[e]); |
|
523 |
DUMPBITS(e) |
|
524 |
||
525 |
/* do the copy */ |
|
526 |
do { |
|
1839 | 527 |
n -= (e = (e = WSIZE - ((d &= WSIZE-1) > w ? d : w)) > n ? n : e); |
636 | 528 |
#ifndef NOMEMCPY |
1839 | 529 |
if (w - d >= e) /* (this test assumes unsigned comparison) */ |
530 |
{ |
|
636 | 531 |
# ifdef USE_MEMCPY |
1839 | 532 |
memcpy(slide + w, slide + d, e); |
636 | 533 |
# else |
1839 | 534 |
bcopy(slide + d, slide + w, e); |
636 | 535 |
# endif |
1839 | 536 |
w += e; |
537 |
d += e; |
|
538 |
} |
|
539 |
else /* do it slow to avoid memcpy() overlap */ |
|
636 | 540 |
#endif /* !NOMEMCPY */ |
1839 | 541 |
do { |
542 |
slide[w++] = slide[d++]; |
|
543 |
} while (--e); |
|
544 |
if (w == WSIZE) |
|
545 |
{ |
|
546 |
FLUSH(w); |
|
547 |
w = 0; |
|
548 |
} |
|
636 | 549 |
} while (n); |
550 |
} |
|
551 |
} |
|
552 |
||
553 |
||
554 |
/* restore the globals from the locals */ |
|
555 |
wp = w; /* restore global window pointer */ |
|
556 |
bb = b; /* restore global bit buffer */ |
|
557 |
bk = k; |
|
558 |
||
559 |
||
560 |
/* done */ |
|
561 |
return 0; |
|
562 |
} |
|
563 |
||
564 |
#endif /* ASM_INFLATECODES */ |
|
565 |
||
566 |
||
567 |
||
568 |
/* "decompress" an inflated type 0 (stored) block. */ |
|
1839 | 569 |
static int |
636 | 570 |
inflate_stored() |
571 |
{ |
|
572 |
unsigned n; /* number of bytes in block */ |
|
573 |
unsigned w; /* current window position */ |
|
574 |
register ulong b; /* bit buffer */ |
|
575 |
register unsigned k; /* number of bits in bit buffer */ |
|
576 |
||
577 |
||
578 |
/* make local copies of globals */ |
|
579 |
Trace((stderr, "stored block\n")); |
|
580 |
b = bb; /* initialize bit buffer */ |
|
581 |
k = bk; |
|
582 |
w = wp; /* initialize window position */ |
|
583 |
||
584 |
||
585 |
/* go to byte boundary */ |
|
586 |
n = k & 7; |
|
587 |
DUMPBITS(n); |
|
588 |
||
589 |
||
590 |
/* get the length and its complement */ |
|
591 |
NEEDBITS(16) |
|
592 |
n = ((unsigned)b & 0xffff); |
|
593 |
DUMPBITS(16) |
|
594 |
NEEDBITS(16) |
|
595 |
if (n != (unsigned)((~b) & 0xffff)) |
|
596 |
return 1; /* error in compressed data */ |
|
597 |
DUMPBITS(16) |
|
598 |
||
599 |
||
600 |
/* read and output the compressed data */ |
|
601 |
while (n--) |
|
602 |
{ |
|
603 |
NEEDBITS(8) |
|
604 |
slide[w++] = (uchar)b; |
|
605 |
if (w == WSIZE) |
|
606 |
{ |
|
607 |
FLUSH(w); |
|
608 |
w = 0; |
|
609 |
} |
|
610 |
DUMPBITS(8) |
|
611 |
} |
|
612 |
||
613 |
||
614 |
/* restore the globals from the locals */ |
|
615 |
wp = w; /* restore global window pointer */ |
|
616 |
bb = b; /* restore global bit buffer */ |
|
617 |
bk = k; |
|
618 |
return 0; |
|
619 |
} |
|
620 |
||
621 |
||
622 |
/* Globals for literal tables (built once) */ |
|
623 |
static struct huft *fixed_tl = (struct huft *)NULL; |
|
624 |
static struct huft *fixed_td = (struct huft *)NULL; |
|
625 |
static int fixed_bl, fixed_bd; |
|
626 |
||
627 |
/* decompress an inflated type 1 (fixed Huffman codes) block. We should |
|
628 |
either replace this with a custom decoder, or at least precompute the |
|
629 |
Huffman tables. */ |
|
1839 | 630 |
static int |
636 | 631 |
inflate_fixed() |
632 |
{ |
|
633 |
/* if first time, set up tables for fixed blocks */ |
|
634 |
Trace((stderr, "fixed block\n")); |
|
635 |
if (fixed_tl == (struct huft *)NULL) |
|
636 |
{ |
|
637 |
int i; /* temporary variable */ |
|
638 |
static unsigned l[288]; /* length list for huft_build */ |
|
639 |
||
640 |
/* literal table */ |
|
641 |
for (i = 0; i < 144; i++) |
|
642 |
l[i] = 8; |
|
643 |
for (; i < 256; i++) |
|
644 |
l[i] = 9; |
|
645 |
for (; i < 280; i++) |
|
646 |
l[i] = 7; |
|
647 |
for (; i < 288; i++) /* make a complete, but wrong code set */ |
|
648 |
l[i] = 8; |
|
649 |
fixed_bl = 7; |
|
650 |
if ((i = huft_build(l, 288, 257, cplens, cplext, |
|
1839 | 651 |
&fixed_tl, &fixed_bl)) != 0) |
636 | 652 |
{ |
653 |
Trace((stderr, "incomplete code set 1\n")); |
|
654 |
fixed_tl = (struct huft *)NULL; |
|
655 |
return i; |
|
656 |
} |
|
657 |
||
658 |
/* distance table */ |
|
659 |
for (i = 0; i < 30; i++) /* make an incomplete code set */ |
|
660 |
l[i] = 5; |
|
661 |
fixed_bd = 5; |
|
662 |
if ((i = huft_build(l, 30, 0, cpdist, cpdext, &fixed_td, &fixed_bd)) > 1) |
|
663 |
{ |
|
664 |
Trace((stderr, "incomplete code set 2\n")); |
|
665 |
huft_free(fixed_tl); |
|
666 |
fixed_tl = (struct huft *)NULL; |
|
667 |
return i; |
|
668 |
} |
|
669 |
} |
|
670 |
||
671 |
||
672 |
/* decompress until an end-of-block code */ |
|
673 |
return inflate_codes(fixed_tl, fixed_td, fixed_bl, fixed_bd) != 0; |
|
674 |
} |
|
675 |
||
676 |
||
677 |
||
678 |
/* decompress an inflated type 2 (dynamic Huffman codes) block. */ |
|
1839 | 679 |
static int |
636 | 680 |
inflate_dynamic() |
681 |
{ |
|
682 |
int i; /* temporary variables */ |
|
683 |
unsigned j; |
|
684 |
unsigned l; /* last length */ |
|
685 |
unsigned m; /* mask for bit lengths table */ |
|
686 |
unsigned n; /* number of lengths to get */ |
|
687 |
struct huft *tl; /* literal/length code table */ |
|
688 |
struct huft *td; /* distance code table */ |
|
689 |
int bl; /* lookup bits for tl */ |
|
690 |
int bd; /* lookup bits for td */ |
|
691 |
unsigned nb; /* number of bit length codes */ |
|
692 |
unsigned nl; /* number of literal/length codes */ |
|
693 |
unsigned nd; /* number of distance codes */ |
|
694 |
#ifdef PKZIP_BUG_WORKAROUND |
|
695 |
static unsigned ll[288+32]; /* literal/length and distance code lengths */ |
|
696 |
#else |
|
697 |
static unsigned ll[286+30]; /* literal/length and distance code lengths */ |
|
698 |
#endif |
|
699 |
register ulong b; /* bit buffer */ |
|
700 |
register unsigned k; /* number of bits in bit buffer */ |
|
701 |
||
702 |
||
703 |
/* make local bit buffer */ |
|
704 |
Trace((stderr, "dynamic block\n")); |
|
705 |
b = bb; |
|
706 |
k = bk; |
|
707 |
||
708 |
||
709 |
/* read in table lengths */ |
|
710 |
NEEDBITS(5) |
|
711 |
nl = 257 + ((unsigned)b & 0x1f); /* number of literal/length codes */ |
|
712 |
DUMPBITS(5) |
|
713 |
NEEDBITS(5) |
|
714 |
nd = 1 + ((unsigned)b & 0x1f); /* number of distance codes */ |
|
715 |
DUMPBITS(5) |
|
716 |
NEEDBITS(4) |
|
717 |
nb = 4 + ((unsigned)b & 0xf); /* number of bit length codes */ |
|
718 |
DUMPBITS(4) |
|
719 |
#ifdef PKZIP_BUG_WORKAROUND |
|
720 |
if (nl > 288 || nd > 32) |
|
721 |
#else |
|
722 |
if (nl > 286 || nd > 30) |
|
723 |
#endif |
|
724 |
{ |
|
725 |
Trace((stderr, "bad length\n")); |
|
726 |
return 1; /* bad lengths */ |
|
727 |
} |
|
728 |
||
729 |
||
730 |
/* read in bit-length-code lengths */ |
|
731 |
for (j = 0; j < nb; j++) |
|
732 |
{ |
|
733 |
NEEDBITS(3) |
|
734 |
ll[border[j]] = (unsigned)b & 7; |
|
735 |
DUMPBITS(3) |
|
736 |
} |
|
737 |
for (; j < 19; j++) |
|
738 |
ll[border[j]] = 0; |
|
739 |
||
740 |
||
741 |
/* build decoding table for trees--single level, 7 bit lookup */ |
|
742 |
bl = 7; |
|
743 |
if ((i = huft_build(ll, 19, 19, NULL, NULL, &tl, &bl)) != 0) |
|
744 |
{ |
|
745 |
if (i == 1) |
|
746 |
huft_free(tl); |
|
747 |
Trace((stderr, "incomplete code set 3\n")); |
|
748 |
return i; /* incomplete code set */ |
|
749 |
} |
|
750 |
||
751 |
||
752 |
/* read in literal and distance code lengths */ |
|
753 |
n = nl + nd; |
|
754 |
m = mask[bl]; |
|
755 |
i = l = 0; |
|
756 |
while ((unsigned)i < n) |
|
757 |
{ |
|
758 |
NEEDBITS((unsigned)bl) |
|
759 |
j = (td = tl + ((unsigned)b & m))->b; |
|
760 |
DUMPBITS(j) |
|
761 |
j = td->v.n; |
|
762 |
if (j < 16) /* length of code in bits (0..15) */ |
|
763 |
ll[i++] = l = j; /* save last length in l */ |
|
764 |
else if (j == 16) /* repeat last length 3 to 6 times */ |
|
765 |
{ |
|
766 |
NEEDBITS(2) |
|
767 |
j = 3 + ((unsigned)b & 3); |
|
768 |
DUMPBITS(2) |
|
769 |
if ((unsigned)i + j > n) |
|
1839 | 770 |
return 1; |
636 | 771 |
while (j--) |
1839 | 772 |
ll[i++] = l; |
636 | 773 |
} |
774 |
else if (j == 17) /* 3 to 10 zero length codes */ |
|
775 |
{ |
|
776 |
NEEDBITS(3) |
|
777 |
j = 3 + ((unsigned)b & 7); |
|
778 |
DUMPBITS(3) |
|
779 |
if ((unsigned)i + j > n) |
|
1839 | 780 |
return 1; |
636 | 781 |
while (j--) |
1839 | 782 |
ll[i++] = 0; |
636 | 783 |
l = 0; |
784 |
} |
|
785 |
else /* j == 18: 11 to 138 zero length codes */ |
|
786 |
{ |
|
787 |
NEEDBITS(7) |
|
788 |
j = 11 + ((unsigned)b & 0x7f); |
|
789 |
DUMPBITS(7) |
|
790 |
if ((unsigned)i + j > n) |
|
1839 | 791 |
return 1; |
636 | 792 |
while (j--) |
1839 | 793 |
ll[i++] = 0; |
636 | 794 |
l = 0; |
795 |
} |
|
796 |
} |
|
797 |
||
798 |
||
799 |
/* free decoding table for trees */ |
|
800 |
huft_free(tl); |
|
801 |
||
802 |
||
803 |
/* restore the global bit buffer */ |
|
804 |
bb = b; |
|
805 |
bk = k; |
|
806 |
||
807 |
||
808 |
/* build the decoding tables for literal/length and distance codes */ |
|
809 |
bl = lbits; |
|
810 |
if ((i = huft_build(ll, nl, 257, cplens, cplext, &tl, &bl)) != 0) |
|
811 |
{ |
|
812 |
Trace((stderr, "incomplete code set 4\n")); |
|
813 |
if (i == 1 && !qflag) { |
|
814 |
Trace((stderr, "incomplete l-tree\n")); |
|
815 |
huft_free(tl); |
|
816 |
} |
|
817 |
return i; /* incomplete code set */ |
|
818 |
} |
|
819 |
bd = dbits; |
|
820 |
if ((i = huft_build(ll + nl, nd, 0, cpdist, cpdext, &td, &bd)) != 0) |
|
821 |
{ |
|
822 |
Trace((stderr, "huft_build err\n")); |
|
823 |
if (i == 1 && !qflag) { |
|
824 |
Trace((stderr, "incomplete d-tree\n")); |
|
825 |
#ifdef PKZIP_BUG_WORKAROUND |
|
826 |
i = 0; |
|
827 |
} |
|
828 |
#else |
|
829 |
huft_free(td); |
|
830 |
} |
|
831 |
huft_free(tl); |
|
832 |
return i; /* incomplete code set */ |
|
833 |
#endif |
|
834 |
} |
|
835 |
||
836 |
||
837 |
/* decompress until an end-of-block code */ |
|
838 |
if (inflate_codes(tl, td, bl, bd)) { |
|
839 |
Trace((stderr, "inflate_codes error\n")); |
|
840 |
return 1; |
|
841 |
} |
|
842 |
||
843 |
||
844 |
/* free the decoding tables, return */ |
|
845 |
huft_free(tl); |
|
846 |
huft_free(td); |
|
847 |
Trace((stderr, "block ok\n")); |
|
848 |
return 0; |
|
849 |
} |
|
850 |
||
851 |
||
852 |
||
853 |
/* decompress an inflated block */ |
|
1839 | 854 |
static int |
637 | 855 |
inflate_block(endPtr) |
856 |
int *endPtr; /* last block flag */ |
|
636 | 857 |
{ |
858 |
unsigned t; /* block type */ |
|
859 |
register ulong b; /* bit buffer */ |
|
860 |
register unsigned k; /* number of bits in bit buffer */ |
|
861 |
||
862 |
||
637 | 863 |
Trace((stderr, "inflate_block\n")); |
864 |
||
636 | 865 |
/* make local bit buffer */ |
866 |
b = bb; |
|
867 |
k = bk; |
|
868 |
||
869 |
||
870 |
/* read in last block bit */ |
|
871 |
NEEDBITS(1) |
|
637 | 872 |
*endPtr = (int)b & 1; |
873 |
Trace((stderr, " end = %d\n", (int)b & 1)); |
|
874 |
||
636 | 875 |
DUMPBITS(1) |
876 |
||
877 |
||
878 |
/* read in block type */ |
|
879 |
NEEDBITS(2) |
|
880 |
t = (unsigned)b & 3; |
|
881 |
DUMPBITS(2) |
|
637 | 882 |
Trace((stderr, " type = %d\n", t)); |
636 | 883 |
|
884 |
||
885 |
/* restore the global bit buffer */ |
|
886 |
bb = b; |
|
887 |
bk = k; |
|
888 |
||
889 |
||
890 |
/* inflate that block type */ |
|
637 | 891 |
if (t == 2) { |
636 | 892 |
return inflate_dynamic(); |
637 | 893 |
} |
894 |
if (t == 0) { |
|
636 | 895 |
return inflate_stored(); |
637 | 896 |
} |
897 |
if (t == 1) { |
|
636 | 898 |
return inflate_fixed(); |
637 | 899 |
} |
636 | 900 |
|
901 |
Trace((stderr, "bad block type\n")); |
|
902 |
/* bad block type */ |
|
903 |
return 2; |
|
904 |
} |
|
905 |
||
906 |
||
907 |
||
908 |
/* decompress an inflated entry */ |
|
1839 | 909 |
static int |
636 | 910 |
inflate() |
911 |
{ |
|
637 | 912 |
int endFlag; /* last block flag */ |
636 | 913 |
int r; /* result code */ |
914 |
unsigned h; /* maximum struct huft's malloc'ed */ |
|
915 |
||
916 |
/* initialize window, bit buffer */ |
|
917 |
wp = 0; |
|
918 |
bk = 0; |
|
919 |
bb = 0; |
|
920 |
||
637 | 921 |
endFlag = 0; |
636 | 922 |
|
923 |
/* decompress until the last block */ |
|
924 |
h = 0; |
|
925 |
do { |
|
926 |
hufts = 0; |
|
637 | 927 |
if ((r = inflate_block(&endFlag)) != 0) { |
928 |
Trace((stderr, "inflate_block -> %d\n", r)); |
|
636 | 929 |
return r; |
637 | 930 |
} |
636 | 931 |
if (hufts > h) |
932 |
h = hufts; |
|
637 | 933 |
} while (!endFlag); |
636 | 934 |
|
935 |
||
936 |
/* flush out slide */ |
|
937 |
FLUSH(wp); |
|
938 |
||
939 |
||
940 |
/* return success */ |
|
941 |
Trace((stderr, "%u bytes in Huffman tables (%d/entry)\n", |
|
1839 | 942 |
h * sizeof(struct huft), sizeof(struct huft))); |
636 | 943 |
return 0; |
944 |
} |
|
945 |
||
946 |
||
947 |
||
1839 | 948 |
static int |
636 | 949 |
inflate_free() |
950 |
{ |
|
951 |
if (fixed_td != (struct huft *)NULL) |
|
952 |
{ |
|
953 |
huft_free(fixed_td); |
|
954 |
fixed_td = (struct huft *)NULL; |
|
955 |
} |
|
956 |
||
957 |
if (fixed_tl != (struct huft *)NULL) |
|
958 |
{ |
|
959 |
huft_free(fixed_tl); |
|
960 |
fixed_tl = (struct huft *)NULL; |
|
961 |
} |
|
962 |
return 0; |
|
963 |
} |
|
964 |
||
965 |
||
1839 | 966 |
static int |
636 | 967 |
stx_inflate(in, out) |
968 |
char *in, *out; |
|
969 |
{ |
|
970 |
int rslt; |
|
1749 | 971 |
extern void *malloc(); |
636 | 972 |
|
973 |
inPtr = in; |
|
974 |
outPtr = out; |
|
1564 | 975 |
slide = malloc(WSIZE+2); |
637 | 976 |
if (! slide) return 1; |
636 | 977 |
|
978 |
rslt = inflate(); |
|
979 |
inflate_free(); |
|
637 | 980 |
free(slide); |
636 | 981 |
return rslt; |
982 |
} |
|
983 |
||
984 |
%} |
|
985 |
! ! |
|
986 |
||
622 | 987 |
!ZipArchive class methodsFor:'documentation'! |
988 |
||
1839 | 989 |
copyright |
624 | 990 |
" |
991 |
COPYRIGHT (c) 1998 by eXept Software AG |
|
1839 | 992 |
All Rights Reserved |
624 | 993 |
|
994 |
This software is furnished under a license and may be used |
|
995 |
only in accordance with the terms of that license and with the |
|
996 |
inclusion of the above copyright notice. This software may not |
|
997 |
be provided or otherwise made available to, or used by, any |
|
998 |
other person. No title to or ownership of the software is |
|
999 |
hereby transferred. |
|
1000 |
" |
|
1001 |
||
1002 |
! |
|
622 | 1003 |
|
624 | 1004 |
documentation |
1005 |
" |
|
1006 |
provides access to a zip archive. |
|
1820 | 1007 |
Caveat: the only compression method (for now) is deflate. |
651 | 1008 |
|
1009 |
[author:] |
|
1839 | 1010 |
Claus Gittinger |
624 | 1011 |
" |
1012 |
! |
|
1013 |
||
1014 |
examples |
|
1015 |
" |
|
1839 | 1016 |
[exBegin] |
624 | 1017 |
|zip bytes| |
1018 |
||
1019 |
zip := ZipArchive oldFileNamed:'foo.zip'. |
|
1020 |
bytes := zip extract:'bar'. |
|
1839 | 1021 |
[exEnd] |
636 | 1022 |
|
1839 | 1023 |
[exBegin] |
636 | 1024 |
|zip bytes| |
1025 |
||
1026 |
zip := ZipArchive oldFileNamed:'source/stx/libbasic2.zip'. |
|
1027 |
zip entries do:[:entry | |
|
1839 | 1028 |
Transcript showCR:entry |
636 | 1029 |
]. |
1839 | 1030 |
[exEnd] |
636 | 1031 |
|
1839 | 1032 |
[exBegin] |
636 | 1033 |
|zip bytes| |
1034 |
||
1035 |
zip := ZipArchive oldFileNamed:'source/stx/libbasic2.zip'. |
|
1036 |
bytes := zip extract:'TwoByteStr.st'. |
|
1037 |
Transcript showCR:(bytes asString). |
|
1839 | 1038 |
[exEnd] |
624 | 1039 |
" |
622 | 1040 |
! ! |
1041 |
||
1042 |
!ZipArchive class methodsFor:'instance creation'! |
|
1043 |
||
1044 |
newFileNamed:name |
|
1045 |
^ self new name:name mode:#write |
|
1046 |
||
1047 |
"Created: / 29.3.1998 / 17:46:16 / cg" |
|
1048 |
! |
|
1049 |
||
1050 |
oldFileNamed:name |
|
635 | 1051 |
|zar f fn| |
628
27102a6bd3f7
remember recently visited zipArchives for faster access
Claus Gittinger <cg@exept.de>
parents:
625
diff
changeset
|
1052 |
|
27102a6bd3f7
remember recently visited zipArchives for faster access
Claus Gittinger <cg@exept.de>
parents:
625
diff
changeset
|
1053 |
RecentlyUsedZipArchives isNil ifTrue:[ |
1839 | 1054 |
RecentlyUsedZipArchives := OrderedCollection new |
628
27102a6bd3f7
remember recently visited zipArchives for faster access
Claus Gittinger <cg@exept.de>
parents:
625
diff
changeset
|
1055 |
]. |
635 | 1056 |
f := name asFilename. |
953 | 1057 |
f exists ifFalse:[^ nil]. |
1058 |
||
635 | 1059 |
fn := f pathName. |
628
27102a6bd3f7
remember recently visited zipArchives for faster access
Claus Gittinger <cg@exept.de>
parents:
625
diff
changeset
|
1060 |
RecentlyUsedZipArchives keysAndValuesDo:[:i :z | |
1839 | 1061 |
z name = fn ifTrue:[ |
1062 |
RecentlyUsedZipArchives removeIndex:i. |
|
1063 |
RecentlyUsedZipArchives addLast:z. |
|
1064 |
self installFlushBlock. |
|
1065 |
^ z |
|
1066 |
]. |
|
628
27102a6bd3f7
remember recently visited zipArchives for faster access
Claus Gittinger <cg@exept.de>
parents:
625
diff
changeset
|
1067 |
]. |
635 | 1068 |
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
|
1069 |
RecentlyUsedZipArchives add:zar. |
701
90faf30c20eb
increased number of cached zipFiles
Claus Gittinger <cg@exept.de>
parents:
700
diff
changeset
|
1070 |
[RecentlyUsedZipArchives size > 15] whileTrue:[ |
1839 | 1071 |
RecentlyUsedZipArchives removeFirst |
628
27102a6bd3f7
remember recently visited zipArchives for faster access
Claus Gittinger <cg@exept.de>
parents:
625
diff
changeset
|
1072 |
]. |
638
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
1073 |
self installFlushBlock. |
628
27102a6bd3f7
remember recently visited zipArchives for faster access
Claus Gittinger <cg@exept.de>
parents:
625
diff
changeset
|
1074 |
^ zar |
622 | 1075 |
|
1076 |
"Created: / 29.3.1998 / 17:46:09 / cg" |
|
701
90faf30c20eb
increased number of cached zipFiles
Claus Gittinger <cg@exept.de>
parents:
700
diff
changeset
|
1077 |
"Modified: / 20.10.1998 / 00:30:02 / cg" |
622 | 1078 |
! ! |
1079 |
||
1080 |
!ZipArchive class methodsFor:'class initialization'! |
|
1081 |
||
1082 |
initialize |
|
1083 |
ECREC_SIZE := 18. |
|
1084 |
LREC_SIZE := 26. |
|
1085 |
CREC_SIZE := 42. |
|
1086 |
||
1087 |
TOTAL_ENTRIES_CENTRAL_DIR := 10. |
|
1088 |
SIZE_CENTRAL_DIRECTORY := 12. |
|
1089 |
||
1090 |
C_COMPRESSED_SIZE := 16. |
|
1091 |
C_UNCOMPRESSED_SIZE := 20. |
|
1092 |
C_FILENAME_LENGTH := 24. |
|
1093 |
C_RELATIVE_OFFSET_LOCAL_HEADER := 38. |
|
1094 |
||
938
4544b3c105fe
fixed directory reading (care for comment and extra-header bytes)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1095 |
C_LOCALHEADERSIGNATURE := 16r04034b50. |
4544b3c105fe
fixed directory reading (care for comment and extra-header bytes)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1096 |
C_CENTRALHEADERSIGNATURE := 16r02014b50. |
4544b3c105fe
fixed directory reading (care for comment and extra-header bytes)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1097 |
C_CENTRALENDSIGNATURE := 16r06054b50. |
4544b3c105fe
fixed directory reading (care for comment and extra-header bytes)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1098 |
|
1839 | 1099 |
"/ compression methods |
1100 |
COMPR_STORED := 0. |
|
622 | 1101 |
COMPR_SHRUNK := 1. |
1102 |
COMPR_REDUCED1 := 2. |
|
1103 |
COMPR_REDUCED2 := 3. |
|
1104 |
COMPR_REDUCED3 := 4. |
|
1105 |
COMPR_REDUCED4 := 5. |
|
1106 |
COMPR_IMPLODED := 6. |
|
1107 |
COMPR_TOKENIZED := 7. |
|
1108 |
COMPR_DEFLATED := 8. |
|
1109 |
||
938
4544b3c105fe
fixed directory reading (care for comment and extra-header bytes)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1110 |
ZipFileFormatErrorSignal isNil ifTrue:[ |
1839 | 1111 |
ZipFileFormatErrorSignal := Error newSignalMayProceed:true. |
1112 |
ZipFileFormatErrorSignal nameClass:self message:#zipFileFormatErrorSignal. |
|
1113 |
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
|
1114 |
]. |
622 | 1115 |
|
1116 |
" |
|
1117 |
self initialize |
|
1118 |
" |
|
1119 |
||
1120 |
"Modified: / 29.3.1998 / 20:17:18 / cg" |
|
1121 |
! ! |
|
1122 |
||
629
33fcaf60afa3
remember recently visited zipArchives for faster access
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
1123 |
!ZipArchive class methodsFor:'cleanup'! |
33fcaf60afa3
remember recently visited zipArchives for faster access
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
1124 |
|
900 | 1125 |
flush |
1126 |
"forget about cached zipArchives" |
|
1127 |
||
1128 |
RecentlyUsedZipArchives := nil. FlushBlock := nil. |
|
1129 |
||
1130 |
" |
|
1131 |
self flush |
|
1132 |
" |
|
1133 |
! |
|
1134 |
||
638
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
1135 |
installFlushBlock |
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
1136 |
"forget about cached zipArchives" |
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
1137 |
|
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
1138 |
FlushBlock isNil ifTrue:[ |
1839 | 1139 |
FlushBlock := [ RecentlyUsedZipArchives := nil. FlushBlock := nil. ]. |
700
b1c6920cfef6
keep more zipArchive-dirs cached.
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
1140 |
] ifFalse:[ |
1839 | 1141 |
Processor removeTimedBlock:FlushBlock. |
638
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
1142 |
]. |
641 | 1143 |
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
|
1144 |
|
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
1145 |
" |
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
1146 |
self installFlushBlock |
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
1147 |
" |
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
1148 |
|
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
1149 |
"Created: / 9.4.1998 / 13:17:07 / cg" |
700
b1c6920cfef6
keep more zipArchive-dirs cached.
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
1150 |
"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
|
1151 |
! |
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
1152 |
|
629
33fcaf60afa3
remember recently visited zipArchives for faster access
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
1153 |
lowSpaceCleanup |
635 | 1154 |
"forget about cached zipArchives" |
1155 |
||
629
33fcaf60afa3
remember recently visited zipArchives for faster access
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
1156 |
RecentlyUsedZipArchives := nil |
33fcaf60afa3
remember recently visited zipArchives for faster access
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
1157 |
|
635 | 1158 |
" |
1159 |
self lowSpaceCleanup |
|
1160 |
" |
|
1161 |
||
1162 |
"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
|
1163 |
! ! |
33fcaf60afa3
remember recently visited zipArchives for faster access
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
1164 |
|
622 | 1165 |
!ZipArchive class methodsFor:'constants'! |
1166 |
||
1167 |
LREC_SIZE |
|
1168 |
^ LREC_SIZE |
|
1169 |
||
1170 |
"Created: / 29.3.1998 / 19:11:20 / cg" |
|
1171 |
! ! |
|
1172 |
||
766
4c422664dcc8
care for bad zipFile entries.
Claus Gittinger <cg@exept.de>
parents:
726
diff
changeset
|
1173 |
!ZipArchive class methodsFor:'debugging'! |
4c422664dcc8
care for bad zipFile entries.
Claus Gittinger <cg@exept.de>
parents:
726
diff
changeset
|
1174 |
|
4c422664dcc8
care for bad zipFile entries.
Claus Gittinger <cg@exept.de>
parents:
726
diff
changeset
|
1175 |
debugTrace:aBoolean |
4c422664dcc8
care for bad zipFile entries.
Claus Gittinger <cg@exept.de>
parents:
726
diff
changeset
|
1176 |
%{ |
4c422664dcc8
care for bad zipFile entries.
Claus Gittinger <cg@exept.de>
parents:
726
diff
changeset
|
1177 |
if (aBoolean == true) { |
1839 | 1178 |
debugTrace = 1; |
766
4c422664dcc8
care for bad zipFile entries.
Claus Gittinger <cg@exept.de>
parents:
726
diff
changeset
|
1179 |
} else { |
1839 | 1180 |
debugTrace = 0; |
766
4c422664dcc8
care for bad zipFile entries.
Claus Gittinger <cg@exept.de>
parents:
726
diff
changeset
|
1181 |
} |
4c422664dcc8
care for bad zipFile entries.
Claus Gittinger <cg@exept.de>
parents:
726
diff
changeset
|
1182 |
%} |
4c422664dcc8
care for bad zipFile entries.
Claus Gittinger <cg@exept.de>
parents:
726
diff
changeset
|
1183 |
! ! |
4c422664dcc8
care for bad zipFile entries.
Claus Gittinger <cg@exept.de>
parents:
726
diff
changeset
|
1184 |
|
622 | 1185 |
!ZipArchive methodsFor:'accessing'! |
1186 |
||
1187 |
entries |
|
1188 |
"return a collection of fileName entries" |
|
1189 |
||
1190 |
|names| |
|
1191 |
||
1192 |
names := OrderedCollection new. |
|
1193 |
||
1194 |
self zipMembersDo:[:zipd | |
|
1839 | 1195 |
names add:(zipd name) |
622 | 1196 |
]. |
1197 |
^ names |
|
1198 |
||
1199 |
" |
|
1200 |
(ZipArchive oldFileNamed:'/usr/lib/java/lib/classes.zip') entries |
|
1201 |
" |
|
1202 |
||
1203 |
"Modified: / 29.3.1998 / 20:08:38 / cg" |
|
1204 |
! |
|
1205 |
||
1206 |
extract:fileName |
|
767 | 1207 |
"extract a filename entry as a byteArray; |
1208 |
nil on errors" |
|
636 | 1209 |
|
719 | 1210 |
|zmemb rawContents data oldEntry| |
638
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
1211 |
|
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
1212 |
recentlyExtractedEntries isNil ifTrue:[ |
1839 | 1213 |
recentlyExtractedEntries := OrderedCollection new |
638
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
1214 |
]. |
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
1215 |
recentlyExtractedEntries keysAndValuesDo:[:index :entry | |
1839 | 1216 |
(entry notNil and:[entry name = fileName]) ifTrue:[ |
1217 |
recentlyExtractedEntries removeIndex:index. |
|
1218 |
recentlyExtractedEntries addLast:entry. |
|
1219 |
data := entry data. |
|
1220 |
data notNil ifTrue:[ |
|
1221 |
^ data |
|
1222 |
] |
|
1223 |
] |
|
638
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
1224 |
]. |
622 | 1225 |
|
1226 |
zmemb := self findMember:fileName. |
|
625 | 1227 |
zmemb isNil ifTrue:[^ nil]. |
1228 |
||
1229 |
self openFile. |
|
1150
e9fe3696d93d
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1149
diff
changeset
|
1230 |
file position0Based:(zmemb fileStart). |
622 | 1231 |
rawContents := file nextBytes:(zmemb compressed_size). |
625 | 1232 |
self closeFile. |
638
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
1233 |
|
1839 | 1234 |
data := self |
1235 |
decode:rawContents |
|
1236 |
method:(zmemb compression_method) |
|
1237 |
size:(zmemb uncompressed_size). |
|
638
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
1238 |
|
719 | 1239 |
data size < (32*1024) ifTrue:[ |
1240 |
"/ zmemb data:data. |
|
1839 | 1241 |
recentlyExtractedEntries addLast:zmemb. |
1242 |
[recentlyExtractedEntries size > 5] whileTrue:[ |
|
1243 |
oldEntry := recentlyExtractedEntries removeFirst. |
|
1244 |
oldEntry data:nil. |
|
1245 |
]. |
|
638
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
1246 |
]. |
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
1247 |
^ data. |
622 | 1248 |
|
1249 |
" |
|
1250 |
(ZipArchive oldFileNamed:'/usr/lib/java/lib/classes.zip') extract:'java/io/UTFDataFormatException.class' |
|
1251 |
" |
|
1252 |
||
719 | 1253 |
"Modified: / 10.1.1999 / 17:43:25 / cg" |
622 | 1254 |
! |
1255 |
||
1256 |
members |
|
1257 |
"return a collection of members" |
|
1258 |
||
1259 |
|members| |
|
1260 |
||
1261 |
members := OrderedCollection new. |
|
1262 |
||
1263 |
self zipMembersDo:[:zipd | |
|
1839 | 1264 |
members add:zipd |
622 | 1265 |
]. |
1266 |
^ members |
|
1267 |
||
1268 |
" |
|
1269 |
(ZipArchive oldFileNamed:'/usr/lib/java/lib/classes.zip') members |
|
1270 |
" |
|
1271 |
||
1272 |
"Created: / 29.3.1998 / 20:09:27 / cg" |
|
1273 |
"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
|
1274 |
! |
27102a6bd3f7
remember recently visited zipArchives for faster access
Claus Gittinger <cg@exept.de>
parents:
625
diff
changeset
|
1275 |
|
27102a6bd3f7
remember recently visited zipArchives for faster access
Claus Gittinger <cg@exept.de>
parents:
625
diff
changeset
|
1276 |
name |
636 | 1277 |
"return the (file-)name of this zipArchive" |
1278 |
||
628
27102a6bd3f7
remember recently visited zipArchives for faster access
Claus Gittinger <cg@exept.de>
parents:
625
diff
changeset
|
1279 |
^ archiveName |
27102a6bd3f7
remember recently visited zipArchives for faster access
Claus Gittinger <cg@exept.de>
parents:
625
diff
changeset
|
1280 |
|
27102a6bd3f7
remember recently visited zipArchives for faster access
Claus Gittinger <cg@exept.de>
parents:
625
diff
changeset
|
1281 |
"Created: / 6.4.1998 / 10:47:11 / cg" |
622 | 1282 |
! ! |
1283 |
||
1284 |
!ZipArchive methodsFor:'private'! |
|
1285 |
||
625 | 1286 |
closeFile |
717 | 1287 |
file notNil ifTrue:[ |
1839 | 1288 |
file close. |
1289 |
file := nil. |
|
717 | 1290 |
] |
625 | 1291 |
|
1292 |
"Created: / 30.3.1998 / 18:18:10 / cg" |
|
717 | 1293 |
"Modified: / 29.12.1998 / 23:08:27 / cg" |
625 | 1294 |
! |
1295 |
||
624 | 1296 |
name:nm mode:m |
625 | 1297 |
archiveName := nm asFilename name. |
624 | 1298 |
mode := m. |
1299 |
||
952 | 1300 |
mode ~~ #write ifTrue:[ |
1839 | 1301 |
self openFile. |
1302 |
self readDirectory. |
|
1303 |
self closeFile. |
|
622 | 1304 |
] ifFalse:[ |
1839 | 1305 |
"/ self openFile. |
622 | 1306 |
] |
1307 |
||
1308 |
" |
|
1309 |
ZipArchive oldFileNamed:'/usr/lib/java/lib/classes.zip' |
|
1310 |
(ZipArchive oldFileNamed:'/usr/lib/java/lib/classes.zip') entries |
|
1311 |
(ZipArchive oldFileNamed:'/usr/lib/java/lib/classes.zip') extract:'java/io/UTFDataFormatException.class' |
|
1312 |
" |
|
1313 |
||
625 | 1314 |
"Modified: / 30.3.1998 / 18:19:48 / cg" |
1315 |
! |
|
1316 |
||
1317 |
openFile |
|
960 | 1318 |
|fn| |
1319 |
||
625 | 1320 |
file isNil ifTrue:[ |
1839 | 1321 |
fn := archiveName asFilename. |
1322 |
mode ~~ #write ifTrue:[ |
|
1323 |
file := fn readStream. |
|
1324 |
] ifFalse:[ |
|
1325 |
file := fn writeStream |
|
1326 |
]. |
|
1327 |
file binary |
|
625 | 1328 |
]. |
1329 |
||
1330 |
"Created: / 30.3.1998 / 18:18:48 / cg" |
|
1331 |
"Modified: / 30.3.1998 / 18:19:26 / cg" |
|
622 | 1332 |
! ! |
1333 |
||
1199 | 1334 |
!ZipArchive methodsFor:'private-decompression'! |
622 | 1335 |
|
636 | 1336 |
decode:rawBytes method:compressionMethod size:uncompressedSize |
1337 |
|outBytes| |
|
1338 |
||
622 | 1339 |
compressionMethod == COMPR_STORED ifTrue:[ |
1839 | 1340 |
"/ |
1341 |
"/ uncompressed |
|
1342 |
"/ |
|
1343 |
^ rawBytes |
|
622 | 1344 |
]. |
1345 |
||
636 | 1346 |
compressionMethod == COMPR_DEFLATED ifTrue:[ |
1839 | 1347 |
"/ |
1348 |
"/ deflate/inflate algorithm |
|
1349 |
"/ |
|
1350 |
outBytes := ByteArray new:uncompressedSize. |
|
1351 |
^ self inflate:rawBytes to:outBytes |
|
636 | 1352 |
]. |
1353 |
||
1354 |
"/ |
|
1355 |
"/ the other algorithms are not (yet) supported |
|
1356 |
"/ |
|
622 | 1357 |
compressionMethod == COMPR_SHRUNK ifTrue:[ |
1839 | 1358 |
self error:'unsupported compression method: SHRUNK'. |
1359 |
^ nil |
|
622 | 1360 |
]. |
1361 |
compressionMethod == COMPR_REDUCED1 ifTrue:[ |
|
1839 | 1362 |
self error:'unsupported compression method: REDUCED1'. |
1363 |
^ nil |
|
622 | 1364 |
]. |
1365 |
compressionMethod == COMPR_REDUCED2 ifTrue:[ |
|
1839 | 1366 |
self error:'unsupported compression method: REDUCED2'. |
1367 |
^ nil |
|
622 | 1368 |
]. |
1369 |
compressionMethod == COMPR_REDUCED3 ifTrue:[ |
|
1839 | 1370 |
self error:'unsupported compression method: REDUCED3'. |
1371 |
^ nil |
|
622 | 1372 |
]. |
1373 |
compressionMethod == COMPR_REDUCED4 ifTrue:[ |
|
1839 | 1374 |
self error:'unsupported compression method: REDUCED4'. |
1375 |
^ nil |
|
622 | 1376 |
]. |
1377 |
compressionMethod == COMPR_IMPLODED ifTrue:[ |
|
1839 | 1378 |
self error:'unsupported compression method: IMPLODED'. |
1379 |
^ nil |
|
622 | 1380 |
]. |
1381 |
compressionMethod == COMPR_TOKENIZED ifTrue:[ |
|
1839 | 1382 |
self error:'unsupported compression method: TOKENIZED'. |
1383 |
^ nil |
|
622 | 1384 |
]. |
1385 |
||
1386 |
self error:'unsupported compression method'. |
|
1387 |
^ nil |
|
1388 |
||
1389 |
"Created: / 29.3.1998 / 20:14:45 / cg" |
|
636 | 1390 |
"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
|
1391 |
! |
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
1392 |
|
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
1393 |
inflate:inBytes to:outBytes |
723 | 1394 |
|inflateReturnCode| |
638
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
1395 |
|
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
1396 |
%{ /* STACK:32768 */ |
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
1397 |
if (__isByteArray(inBytes) |
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
1398 |
&& __isByteArray(outBytes)) { |
1839 | 1399 |
char *in, *out; |
1400 |
int rc; |
|
638
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
1401 |
|
1839 | 1402 |
in = __ByteArrayInstPtr(inBytes)->ba_element; |
1403 |
out = __ByteArrayInstPtr(outBytes)->ba_element; |
|
638
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
1404 |
|
1839 | 1405 |
if ((rc = stx_inflate(in, out)) == 0) { |
1406 |
RETURN (outBytes); |
|
1407 |
} |
|
1408 |
inflateReturnCode = __MKSMALLINT(rc); |
|
638
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
1409 |
} |
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
1410 |
%}. |
723 | 1411 |
inflateReturnCode notNil ifTrue:[ |
1839 | 1412 |
"/ bad blockType 2 |
1413 |
self error:'inflate error: ' , inflateReturnCode printString |
|
723 | 1414 |
]. |
638
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
1415 |
^ nil. |
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
1416 |
|
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
1417 |
"Created: / 8.4.1998 / 10:31:27 / cg" |
622 | 1418 |
! ! |
1419 |
||
1199 | 1420 |
!ZipArchive methodsFor:'private-directory stuff'! |
622 | 1421 |
|
1422 |
addMember |
|
624 | 1423 |
"add a zipMember" |
1424 |
||
622 | 1425 |
|zmemb | |
1426 |
||
691
5c5cf54ead71
handle errors more gracefully
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
1427 |
self addMember:(zmemb := ZipMember new). |
5c5cf54ead71
handle errors more gracefully
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
1428 |
^ zmemb. |
5c5cf54ead71
handle errors more gracefully
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
1429 |
|
5c5cf54ead71
handle errors more gracefully
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
1430 |
"Created: / 29.3.1998 / 18:22:25 / cg" |
5c5cf54ead71
handle errors more gracefully
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
1431 |
"Modified: / 9.9.1998 / 20:33:32 / cg" |
5c5cf54ead71
handle errors more gracefully
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
1432 |
! |
5c5cf54ead71
handle errors more gracefully
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
1433 |
|
5c5cf54ead71
handle errors more gracefully
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
1434 |
addMember:zmemb |
5c5cf54ead71
handle errors more gracefully
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
1435 |
"add a zipMember" |
5c5cf54ead71
handle errors more gracefully
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
1436 |
|
622 | 1437 |
(firstEntry == nil) ifTrue:[ |
1839 | 1438 |
firstEntry := zmemb |
1439 |
] ifFalse:[ |
|
1440 |
lastEntry next:zmemb. |
|
622 | 1441 |
]. |
1442 |
lastEntry := zmemb. |
|
1443 |
^ zmemb. |
|
1444 |
||
624 | 1445 |
"Modified: / 30.3.1998 / 17:13:20 / cg" |
691
5c5cf54ead71
handle errors more gracefully
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
1446 |
"Created: / 9.9.1998 / 20:33:06 / cg" |
622 | 1447 |
! |
1448 |
||
1449 |
findMember:name |
|
624 | 1450 |
"find a zipMember by name" |
1451 |
||
622 | 1452 |
self zipMembersDo:[:zipd | |
1839 | 1453 |
(zipd name = name) ifTrue:[^ zipd]. |
622 | 1454 |
]. |
1455 |
^ nil |
|
1456 |
||
624 | 1457 |
"Modified: / 30.3.1998 / 17:13:30 / cg" |
622 | 1458 |
! |
1459 |
||
1460 |
readDirectory |
|
624 | 1461 |
"read the zip directory into a linked-list of zipMembers" |
1462 |
||
681
58fcd6034921
search for, if PK-magic is not found at expected file position.
Claus Gittinger <cg@exept.de>
parents:
651
diff
changeset
|
1463 |
|size count_in dir_size foundPK pos0| |
622 | 1464 |
|
1465 |
size := file fileSize. |
|
1466 |
(size == 0) ifTrue:[ |
|
1839 | 1467 |
count_in := 0. |
1468 |
^ self |
|
622 | 1469 |
]. |
1470 |
||
1471 |
(size < (ECREC_SIZE+4)) ifTrue:[ |
|
1839 | 1472 |
^ ZipFileFormatErrorSignal raiseRequestErrorString:' - zipfile too short'. |
622 | 1473 |
]. |
1474 |
||
900 | 1475 |
foundPK := false. |
1150
e9fe3696d93d
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1149
diff
changeset
|
1476 |
file position0Based:(pos0 := size - ECREC_SIZE - 4). |
1418
0bfc19132acd
Use #codePoint instead of deprecated #asciiValue
Stefan Vogel <sv@exept.de>
parents:
1199
diff
changeset
|
1477 |
((file next ~~ ($P codePoint)) |
0bfc19132acd
Use #codePoint instead of deprecated #asciiValue
Stefan Vogel <sv@exept.de>
parents:
1199
diff
changeset
|
1478 |
or:[file next ~~ ($K codePoint) |
625 | 1479 |
or:[file next ~~ 8r005 |
1480 |
or:[file next ~~ 8r006]]]) ifTrue:[ |
|
1839 | 1481 |
"/ search for PK ... |
1482 |
file reset. "/(pos0 - 100). |
|
1483 |
[file atEnd not and:[foundPK not]] whileTrue:[ |
|
1484 |
(file next == ($P codePoint) |
|
1485 |
and:[file next == ($K codePoint) |
|
1486 |
and:[file next == 8r005 |
|
1487 |
and:[file next == 8r006]]]) ifTrue:[ |
|
1488 |
foundPK := true. |
|
1489 |
pos0 := file position0Based - 4. |
|
1490 |
] |
|
1491 |
]. |
|
1492 |
foundPK ifTrue:[ |
|
1493 |
'ZipArchive [warning]: funny format; resynchronized' infoPrintCR. |
|
1494 |
] ifFalse:[ |
|
1495 |
^ ZipFileFormatErrorSignal raiseRequestErrorString:' - invalid zipfile'. |
|
1496 |
] |
|
622 | 1497 |
]. |
1498 |
||
1499 |
file skip: (TOTAL_ENTRIES_CENTRAL_DIR - 4). |
|
1500 |
||
700
b1c6920cfef6
keep more zipArchive-dirs cached.
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
1501 |
count_in := file nextUnsignedShortMSB:false. "/ Get TOTAL_ENTRIES_CENTRAL_DIR |
624 | 1502 |
dir_size := file nextLongMSB:false. "/ Get SIZE_CENTRAL_DIRECTORY |
1473
1a6c411ba49f
Better premature end of file handling
Stefan Vogel <sv@exept.de>
parents:
1418
diff
changeset
|
1503 |
file position0Based:(pos0 - dir_size). |
622 | 1504 |
|
1839 | 1505 |
EndOfStreamNotification handle:[:ex| |
1506 |
self warn:'ZipArchive: file format error or short file: ' , |
|
1507 |
(file isFileStream ifTrue:[file pathName] ifFalse:['inStream']). |
|
1508 |
^ self. |
|
1473
1a6c411ba49f
Better premature end of file handling
Stefan Vogel <sv@exept.de>
parents:
1418
diff
changeset
|
1509 |
] do:[ |
1839 | 1510 |
0 to:(count_in-1) do:[:i | |
1511 |
|zipd filename_length s sig extraFieldLength fileCommentLength relative_offset_local_header |
|
1512 |
pos extra| |
|
1513 |
||
1514 |
zipd := ZipMember new. |
|
1515 |
"/ file skip:(4+C_COMPRESSED_SIZE-4-2-2-2). |
|
1516 |
sig := file nextLongMSB:false. "/ signature |
|
1517 |
file nextUnsignedShortMSB:false. "/ versionMade |
|
1518 |
file nextUnsignedShortMSB:false. "/ versionExtract |
|
1519 |
file nextUnsignedShortMSB:false. "/ flags |
|
938
4544b3c105fe
fixed directory reading (care for comment and extra-header bytes)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1520 |
|
1839 | 1521 |
zipd compression_method:(file nextUnsignedShortMSB:false). "/ Get compression method |
1522 |
(file nextUnsignedShortMSB:false). "/ skip last_mod_file_time |
|
1523 |
(file nextUnsignedShortMSB:false). "/ skip last_mod_file_date |
|
1524 |
zipd crc32:(file nextLongMSB:false). "/ Get crc32 |
|
1525 |
zipd compressed_size:(file nextLongMSB:false). "/ Get C_COMPRESSED_SIZE |
|
1526 |
zipd uncompressed_size:(file nextLongMSB:false). "/ Get C_UNCOMPRESSED_SIZE |
|
1527 |
filename_length := (file nextUnsignedShortMSB:false). "/ Get C_FILENAME_LENGTH |
|
1528 |
"/ file skip:(C_RELATIVE_OFFSET_LOCAL_HEADER-(C_FILENAME_LENGTH+2)). |
|
1529 |
extraFieldLength := (file nextUnsignedShortMSB:false). "/ extraFieldLength |
|
1530 |
fileCommentLength := (file nextUnsignedShortMSB:false). "/ fileCommentLength |
|
1531 |
(file nextUnsignedShortMSB:false). "/ diskNumberStart |
|
1532 |
(file nextUnsignedShortMSB:false). "/ internalFileAttribute |
|
1533 |
(file nextLongMSB:false). "/ externalFileAttribute |
|
1534 |
relative_offset_local_header := file nextLongMSB:false. |
|
938
4544b3c105fe
fixed directory reading (care for comment and extra-header bytes)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1535 |
|
1839 | 1536 |
sig ~= C_CENTRALHEADERSIGNATURE ifTrue:[ |
1537 |
self warn:'ZipArchive: file format error - bad centralHeaderSignature in:' , |
|
1538 |
(file isFileStream ifTrue:[file pathName] ifFalse:['inStream']). |
|
1539 |
^ self. |
|
1540 |
]. |
|
938
4544b3c105fe
fixed directory reading (care for comment and extra-header bytes)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1541 |
|
1839 | 1542 |
pos := file position. |
1543 |
file position0Based:(relative_offset_local_header + 28). |
|
1544 |
extra := file nextUnsignedShortMSB:false. |
|
1545 |
zipd dataStart:(relative_offset_local_header + "C_SIZEOFLOCALHEADER" 30 + filename_length + extra ). |
|
1546 |
file position:pos. |
|
700
b1c6920cfef6
keep more zipArchive-dirs cached.
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
1547 |
|
1839 | 1548 |
zipd name:(s := String new:filename_length). |
1549 |
file nextBytes:filename_length into:s. |
|
1473
1a6c411ba49f
Better premature end of file handling
Stefan Vogel <sv@exept.de>
parents:
1418
diff
changeset
|
1550 |
|
1839 | 1551 |
file skip:(extraFieldLength + fileCommentLength). |
1552 |
self addMember:zipd. |
|
1553 |
] |
|
622 | 1554 |
] |
1555 |
||
900 | 1556 |
" |
938
4544b3c105fe
fixed directory reading (care for comment and extra-header bytes)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1557 |
ZipArchive flush. |
900 | 1558 |
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
|
1559 |
ZipArchive oldFileNamed:'/usr/lib/jdk1.1.8/lib/classes.zip' |
900 | 1560 |
" |
1561 |
||
700
b1c6920cfef6
keep more zipArchive-dirs cached.
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
1562 |
"Modified: / 19.10.1998 / 21:27:32 / cg" |
622 | 1563 |
! |
1564 |
||
1565 |
zipMembersDo:aBlock |
|
624 | 1566 |
"evaluate aBlock for all zipMembers" |
1567 |
||
622 | 1568 |
|zipd| |
1569 |
||
1570 |
zipd := firstEntry. |
|
1571 |
[zipd notNil] whileTrue:[ |
|
1839 | 1572 |
aBlock value:zipd. |
1573 |
zipd := zipd next |
|
622 | 1574 |
]. |
1575 |
||
1576 |
"Created: / 29.3.1998 / 19:15:15 / cg" |
|
624 | 1577 |
"Modified: / 30.3.1998 / 17:13:47 / cg" |
622 | 1578 |
! ! |
1579 |
||
651 | 1580 |
!ZipArchive::ZipMember class methodsFor:'documentation'! |
1581 |
||
1582 |
documentation |
|
1583 |
" |
|
1584 |
keeps some information for a single entry in a zipFile. |
|
1585 |
" |
|
1586 |
||
1587 |
||
1588 |
! ! |
|
1589 |
||
622 | 1590 |
!ZipArchive::ZipMember methodsFor:'accessing'! |
1591 |
||
1592 |
compressed_size |
|
1593 |
"return the value of the instance variable 'compressed_size' (automatically generated)" |
|
1594 |
||
1595 |
^ compressed_size |
|
1596 |
||
1597 |
"Created: / 29.3.1998 / 18:28:03 / cg" |
|
1598 |
! |
|
1599 |
||
1600 |
compressed_size:something |
|
1601 |
"set the value of the instance variable 'compressed_size' (automatically generated)" |
|
1602 |
||
1603 |
compressed_size := something. |
|
1604 |
||
1605 |
"Created: / 29.3.1998 / 18:28:03 / cg" |
|
1606 |
! |
|
1607 |
||
1608 |
compression_method |
|
1609 |
"return the value of the instance variable 'compression_method' (automatically generated)" |
|
1610 |
||
1611 |
^ compression_method |
|
1612 |
||
1613 |
"Created: / 29.3.1998 / 20:02:57 / cg" |
|
1614 |
! |
|
1615 |
||
1616 |
compression_method:something |
|
1617 |
"set the value of the instance variable 'compression_method' (automatically generated)" |
|
1618 |
||
1619 |
compression_method := something. |
|
1620 |
||
1621 |
"Created: / 29.3.1998 / 20:02:57 / cg" |
|
1622 |
! |
|
1623 |
||
1624 |
crc32 |
|
1625 |
"return the value of the instance variable 'crc32' (automatically generated)" |
|
1626 |
||
1627 |
^ crc32 |
|
1628 |
||
1629 |
"Created: / 29.3.1998 / 20:03:00 / cg" |
|
1630 |
! |
|
1631 |
||
1632 |
crc32:something |
|
1633 |
"set the value of the instance variable 'crc32' (automatically generated)" |
|
1634 |
||
1635 |
crc32 := something. |
|
1636 |
||
1637 |
"Created: / 29.3.1998 / 20:03:00 / cg" |
|
1638 |
! |
|
1639 |
||
638
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
1640 |
data |
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
1641 |
"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
|
1642 |
|
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
1643 |
^ data |
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
1644 |
|
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
1645 |
"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
|
1646 |
! |
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
1647 |
|
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
1648 |
data:something |
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
1649 |
"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
|
1650 |
|
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
1651 |
data := something. |
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
1652 |
|
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
1653 |
"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
|
1654 |
! |
ff61e852f5c3
flush cached data after some time (1 minute)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
1655 |
|
938
4544b3c105fe
fixed directory reading (care for comment and extra-header bytes)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1656 |
dataStart |
4544b3c105fe
fixed directory reading (care for comment and extra-header bytes)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1657 |
"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
|
1658 |
|
4544b3c105fe
fixed directory reading (care for comment and extra-header bytes)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1659 |
^ dataStart |
4544b3c105fe
fixed directory reading (care for comment and extra-header bytes)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1660 |
|
4544b3c105fe
fixed directory reading (care for comment and extra-header bytes)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1661 |
"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
|
1662 |
! |
4544b3c105fe
fixed directory reading (care for comment and extra-header bytes)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1663 |
|
4544b3c105fe
fixed directory reading (care for comment and extra-header bytes)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1664 |
dataStart:something |
4544b3c105fe
fixed directory reading (care for comment and extra-header bytes)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1665 |
"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
|
1666 |
|
4544b3c105fe
fixed directory reading (care for comment and extra-header bytes)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1667 |
dataStart := something. |
4544b3c105fe
fixed directory reading (care for comment and extra-header bytes)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1668 |
|
4544b3c105fe
fixed directory reading (care for comment and extra-header bytes)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1669 |
"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
|
1670 |
! |
4544b3c105fe
fixed directory reading (care for comment and extra-header bytes)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1671 |
|
622 | 1672 |
name |
1673 |
"return the value of the instance variable 'name' (automatically generated)" |
|
1674 |
||
1675 |
^ name |
|
1676 |
||
1677 |
"Created: / 29.3.1998 / 18:29:22 / cg" |
|
1678 |
! |
|
1679 |
||
1680 |
name:something |
|
1681 |
"set the value of the instance variable 'name' (automatically generated)" |
|
1682 |
||
1683 |
name := something. |
|
1684 |
||
1685 |
"Created: / 29.3.1998 / 18:29:22 / cg" |
|
1686 |
! |
|
1687 |
||
1688 |
next |
|
1689 |
"return the value of the instance variable 'next' (automatically generated)" |
|
1690 |
||
1691 |
^ next |
|
1692 |
||
1693 |
"Created: / 29.3.1998 / 18:29:42 / cg" |
|
1694 |
! |
|
1695 |
||
1696 |
next:something |
|
1697 |
"set the value of the instance variable 'next' (automatically generated)" |
|
1698 |
||
1699 |
next := something. |
|
1700 |
||
1701 |
"Created: / 29.3.1998 / 18:29:42 / cg" |
|
1702 |
! |
|
1703 |
||
1704 |
uncompressed_size |
|
1705 |
"return the value of the instance variable 'uncompressed_size' (automatically generated)" |
|
1706 |
||
1707 |
^ uncompressed_size |
|
1708 |
||
1709 |
"Created: / 29.3.1998 / 18:28:21 / cg" |
|
1710 |
! |
|
1711 |
||
1712 |
uncompressed_size:something |
|
1713 |
"set the value of the instance variable 'uncompressed_size' (automatically generated)" |
|
1714 |
||
1715 |
uncompressed_size := something. |
|
1716 |
||
1717 |
"Created: / 29.3.1998 / 18:28:21 / cg" |
|
1718 |
! ! |
|
1719 |
||
1720 |
!ZipArchive::ZipMember methodsFor:'printing & storing'! |
|
1721 |
||
1722 |
displayString |
|
634 | 1723 |
^ 'ZipMember(' , (name ? '*nil*') , ')' |
622 | 1724 |
|
1725 |
"Created: / 29.3.1998 / 20:10:07 / cg" |
|
634 | 1726 |
"Modified: / 2.4.1998 / 15:10:08 / cg" |
622 | 1727 |
! ! |
1728 |
||
1729 |
!ZipArchive::ZipMember methodsFor:'queries'! |
|
1730 |
||
1731 |
fileStart |
|
938
4544b3c105fe
fixed directory reading (care for comment and extra-header bytes)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1732 |
^ dataStart |
4544b3c105fe
fixed directory reading (care for comment and extra-header bytes)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1733 |
"/ ^ relative_offset_local_header + ZipArchive LREC_SIZE + 4 + name size |
622 | 1734 |
|
1735 |
"Created: / 29.3.1998 / 19:10:57 / cg" |
|
1736 |
! ! |
|
1737 |
||
628
27102a6bd3f7
remember recently visited zipArchives for faster access
Claus Gittinger <cg@exept.de>
parents:
625
diff
changeset
|
1738 |
!ZipArchive class methodsFor:'documentation'! |
27102a6bd3f7
remember recently visited zipArchives for faster access
Claus Gittinger <cg@exept.de>
parents:
625
diff
changeset
|
1739 |
|
27102a6bd3f7
remember recently visited zipArchives for faster access
Claus Gittinger <cg@exept.de>
parents:
625
diff
changeset
|
1740 |
version |
1839 | 1741 |
^ '$Header: /cvs/stx/stx/libbasic2/ZipArchive.st,v 1.51 2007-01-24 15:12:17 cg Exp $' |
628
27102a6bd3f7
remember recently visited zipArchives for faster access
Claus Gittinger <cg@exept.de>
parents:
625
diff
changeset
|
1742 |
! ! |
1129
8e0da7fb22fb
Use #raiseErrorString: instead of #raiseWith:
Stefan Vogel <sv@exept.de>
parents:
970
diff
changeset
|
1743 |
|
622 | 1744 |
ZipArchive initialize! |