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