home *** CD-ROM | disk | FTP | other *** search
- Reference manual for PKWAREU version 1.0a October 1993
-
- This manual contains information on all Procedures, functions and
- declarations available for use, and discriptions on how to use
- them.
-
- ===================== Functions and Procedures =============================
-
- ------------------------------------------------------------------------------
- GetZipStats
- ------------------------------------------------------------------------------
-
- Syntax:
-
- FUNCTION GetZipStats:WORD;
-
- Returns:
-
- 0 - if Signature found and successfully read into "zipstats".
-
- 1 - if Signature found does not match, the file is either not a
- zip file or has been damaged.
-
- 2 - I do a block read to get the signature, returns 2 if it fails.
-
- Other - higher then 2 are the IOResult errors, as defined
- in your Turbo Pascal Reference.
-
- Description:
-
- Called after the "Zipfile" has been opened and assigned.
- This procedure, finds the CentralFileHeaderSignature, and reads the
- end of the central directory record into the global variable
- "ZipStats". It also sets the CentralAddress variable to the
- start of the central directory upon success.
-
- NOTE Call this before the other routines, I do not
- check to see if has been called successfully.
-
- Programming notes:
-
- Needs 50 bytes free on the heap before calling. This is
- always restored, and it ain't asking for much.
-
- -----------------------------------------------------------------------------
- ReadFileHeader
- -----------------------------------------------------------------------------
-
- Syntax:
-
- FUNCTION ReadFileHeader(VAR CFH: CentralFileHeaderType): Byte;
-
- Returns:
-
- 0 - the read was successful contents of CFH should be Okay to use.
-
- 1 - Signature is bad do not use CHF, may have read past the last entry.
-
- 2 - disk read error, same as GetZipStats error 2 above.
-
- Other - codes are IOResult codes as described above.
-
- Description:
-
- Called after a successful call to GetZipStats above. Loads the
- CFH with the next Centralfileheader discovered. The read is
- sequential. That is the directory is read from start to end, in
- the order they appear. (This does not always correspond to the
- order the files are actually stored in the zip file, however)
- The Offset of the next header is kept in a four byte variable
- internally, calculated at the time of the last read. This will
- allow you to close the Zipfile and reopen it at anytime, but in
- stating that... do not alter the ZipStats fields at anytime.
-
- Programming notes:
-
- Minimum heap use will be 46 bytes which is restored on exit of
- the call. NOTE: that only the filename field is of type string,
- FileComment is a character array. This is done because the length
- discripter for each is a word type not a byte type. Meaning the
- length of these fields is not limited to Pascal String lengths of
- 255. I have "capped" it to 255, set by the Const PKMaxLen. This
- means if these fields are longer then PKMaxLen they will have to
- be read by a different method unless you have the source code to
- change PKMaxLen. This senario also applies to the filename field,
- but should not be of concern for MS-DOS systems where the maximum
- path length is less than 255 characters, or at least I think it is.
-
- ------------------------------------------------------------------------------
- CFH_to_FileStat
- ------------------------------------------------------------------------------
-
- Syntax:
-
- PROCEDURE CFH_to_FileStat(VAR CFH: CentralFileHeaderType;
- VAR FS: FileStats);
-
- Description:
-
- Converts a CentralFileHeaderType to a FileStats type. Included
- because you will most likely write a similar routine to manage
- the contents. CFH's are rather large to keep many in memory at one
- time, so I suggest using this as it contians information of interest.
-
- ------------------------------------------------------------------------------
- ShowZipComment
- ------------------------------------------------------------------------------
-
- Synatx:
-
- PROCEDURE ShowZipComment;
-
- Description:
-
- Writes the Zip comment to the screen. NOTE if you have the freeware
- version only the first 15 charaters will write to screen. PKWARE
- suggests a maximun size of a commment should be 64K.
-
- ------------------------------------------------------------------------------
- GetZipComment
- ------------------------------------------------------------------------------
-
- Syntax:
-
- Procedure GetZipComment(VAR CPtr: CommentPtr; VAR Size:Word);
-
- Description:
-
- Returns a CommentPtr, as declered in types section, to a character
- array, of length SIZE. You are responsible to free the heap
- allocated to the pointer. Range checking must be off for this to
- work. NOTE if you have the freeware version maximun size returned
- is 15. PKWARE suggests a maximum size of a comment should be
- 64k, so WORD type is used for SIZE. Does not check if enough free
- heap exists.
-
- See PKdemo1 for details on correct use!
-
-
- ======================== Symbols, Types and Constants =========================
-
- CONST
-
- CentralFileHeaderSignature = $02014b50; { As defined by PKWARE }
- CentralFileHeaderEndSignature = $06054b50;
-
- PKMaxLen = 255; { Max length of Filecomment and ExtraField }
- CommentLen = 15; { Set to 15 for freeware version }
-
- TYPES
-
- FString = String;
-
- CharArray = Array[1.. PKMaxLen] of CHAR;
-
- CommentPtr = ^CommentPtr;
- CommentArray = Array[1..1] of Char;
-
- => FileStats = Record { just to make storage size managable }
- Name : String[65]; { includes path }
- OSize, { original size }
- CSize, { compressed size }
- Date, { date and time as longint }
- CRC : Longint; { CRC-32 }
- Attr : LongInt; { actually word TYPE in DOS }
- Method : Word; { compression method used }
- end;
-
- => ExtraData = Record
- ExtraName : String[11]; { name of the data }
- ExtraID : Word; { Id number of the data }
- ExtraLen : Word; { length of the data }
- ExtraAddress: Longint; { File offest of the data }
- end;
-
- NOTE: ExtraName is based on the value of ExtraID, first 31 mappings
- are reserved by PKWARE, the rest can be used by a thrid parties.
-
- I set ExtraName to one of :
-
- $0007 = "AV Info"
- $0009 = "OS/2"
- $000C = "VAX/VMS"
- other = "Proprietary" { third party assigned }
-
- => CentralFileHeaderType = Record { a.k.a. CFH }
- CentralSig :LongInt; { Central dir signature }
- Madeby : Word; { HI = Operating system,
- Lo = Pkzip version }
- VerReq : Word; { min PK version to extract }
- GenPurp : Word; { Gen. purpose flag }
- Compresion : Word; { Compersion method used }
- lastFTime : Word; { Time of compression }
- lastFdate : Word; { Date of compression }
- crc32 : LongInt; { Magic number CRC32 }
- Compsize : LongInt; { Compresed file size }
- UnCompSize : LongInt; { Original file size }
- NameLen : Word; { Length of the name }
- Extralen : Word; { Length of extra field }
- ComentLen : Word; { Length of comment }
- DiskStart : Word; { # of disk which this file starts }
- IntrenalAttr : Word; { LO set indicates ASCII text,
- else is a binary file }
- ExternalAttr : LongInt; { HI is operating sys dependant,
- LO is MS-DOS file attr }
- OffsetLocal : LongInt; { Offset from first disk of
- local header }
- FileName : FString; { Storage for filename, }
- ExtraName : ExtraData; { Storage for extra field }
- FileComment : CharArray; { Storage for File comments }
- End;
-
- NOTE: The CentralFileHeaderType is all the information about a stored file
- available. Their should be one for each file stored.
-
- => ZipEndRec = Record
- EndSig : LongInt; { Signature of Directroy End }
- DiskNum : Word; { Number of this disk }
- DiskwStart : Word; { # of disk with start of central dir }
- NumEntries : Word; { # of entries in central dir.
- on this disk }
- TNumEntries : Word; { total number of entries in this
- central dir. }
- SizeCentral : LongInt; { Size of central directory }
- OffsetDirRelDiskNum: LongInt; { Offest of central dir in respect to
- starting disk number }
- CommentLen :Word; { zipfile comment length }
- end;
-
- NOTE: The ZipEndRec is between the last CFH and the zip file comment,
- only one in any zip file.
-
- VAR's
-
- ZipStats : ZipEndRec; { Global zipstats }
-
- NOTE: This record is used internally, so do not change the fields once set
- by calling GetZipStats.
-
- ZipFile :File; { Zip filename.
- NOTE: You open and assign and close it ! }
-
- CentralAddress : LongInt; { Offset of Central directory in file }
- { Never change this! }
-
- { End manual.doc }
-