Zipper


Contents


Introduction and Overview

The Zipper module provides a simple interface for creating and reading Zip archives, using the ZLib module to provide a means of deflating and inflating files.

Zip archives are collections of files, compressed using the deflate algorithm. These files originated with PKWare's PKZip and PKUnzip utilities under DOS. They are now the most widespread means of transferring compressed data. Zip files consist of a catalogue containing information about the objects contained in the file.

The Zip archives created are compatible with PKZip and Info-Zip, which should allow them to be used between operating systems.


Technical Details

The Zipper module provides two different APIs; one for creating Zip archives, and one for extracting data.

File name conventions

Within the Zipper module interface, filenames are referred to with RISC OS semantics. That is, although the archives themselves use period and slash (. and /), these will be reversed when creating or extracting filenames from the archive by the module. Further character translations may occur in future. Unlike RISC OS, filenames are case sensitive.


SWI calls


Zipper_UnZipOpen
(SWI &559C0)

Open an archive for extraction
On entry
R0=Flags :
Bit(s)Meaning
31If set, do not discard this archive handle when the application exits
0-30Reserved, must be 0
R1=Pointer to filename of archive to read
On exit
R0=Opaque unzip handle, guaranteed not to be 0
Interrupts
Interrupts are disabled
Fast interrupts are enabled
Processor mode
Processor is in SVC mode
Re-entrancy
SWI is not re-entrant
Use

This SWI is opens a Zip archive for reading via the Zipper API. If the file cannot be opened, an error will be returned.

Related SWIs
Zipper_UnZipClose

Zipper_UnZipClose
(SWI &559C1)

Close a file, previously opened for extraction
On entry
R0=Flags (reserved, must be 0)
R1=Unzip handle
On exit
None
Interrupts
Interrupts are disabled
Fast interrupts are enabled
Processor mode
Processor is in SVC mode
Re-entrancy
SWI is not re-entrant
Use

This SWI is used to close an archive previously opened for extraction.

Related SWIs
Zipper_UnZipOpen

Zipper_UnZipInfo
(SWI &559C2)

Read information about an open archive
On entry
R0=Flags :
Bit(s)Meaning
0-7Requested information type :
ValueMeaning
0Read number of entries in the archive
1Read archive comment
8-31Reserved, must be 0
R1=Unzip handle
R2-3=dependent on request type
On exit
R0-3=dependent on request type
Interrupts
Interrupts are disabled
Fast interrupts are enabled
Processor mode
Processor is in SVC mode
Re-entrancy
SWI is not re-entrant
Use

This SWI is used to read miscellaneous information about an open archive.

Related SWIs
Zipper_UnZipOpen

Zipper_UnZipInfo 0
(SWI &559C2)

Read number of objects in the archive
On entry
R0=Flags :
Bit(s)Meaning
0-70 (reason code)
8-31Reserved, must be 0
R1=Unzip handle
On exit
R0=number of objects in archive
Interrupts
Interrupts are disabled
Fast interrupts are enabled
Processor mode
Processor is in SVC mode
Re-entrancy
SWI is not re-entrant
Use

This SWI is used to read the number of objects in the archive. 'Objects' includes both files and directories.

Related SWIs
Zipper_UnZipInfo

Zipper_UnZipInfo 1
(SWI &559C2)

Read zip archive comment
On entry
R0=Flags :
Bit(s)Meaning
0-71 (reason code)
8-31Reserved, must be 0
R1=Unzip handle
R2=Pointer to buffer for data
R3=Length of buffer, or -ve to return buffer size requirements
On exit
R0=amount of data read, or required
Interrupts
Interrupts are disabled
Fast interrupts are enabled
Processor mode
Processor is in SVC mode
Re-entrancy
SWI is not re-entrant
Use

This SWI is used to read the comment from a Zip archive. Zip archives can have a user-readable 'comment' section included which describes the content of the archive. This area can be read through this call.

Related SWIs
Zipper_UnZipOpen

Zipper_UnZipEnumerate
(SWI &559C3)

Enumerate the objects in an archive
On entry
R0=Flags :
Bit(s)Meaning
0-16

Elements to return in to the buffer. For each bit set, an integer value will be written into the output buffer (except where stated). Where multiple values are given, they will be stored consecutively.

Bit(s)Meaning
0Version number of creator
Version number required to extract
1General purpose flags (refer to Zip specification)
2Compression method (refer to Zip specification)
3Size of file when compressed
4Size of file when expanded
5Internal file attributes
6External file attributes
7Centisecond (0-99)
Second (0-59)
Minute (0-59)
Hour (0-23)
Date (1-31)
Month (1-12)
Year (0...)
8RISC OS Load address
RISC OS Exec address
9RISC OS Uncompressed length (duplicate of b4)
10RISC OS Attributes
11RISC OS Object type
12RISC OS File type
13GBPB-style filename length (aligned to a multiple of 4)
Zero terminated filename, aligned to a word boundary, inline with this data.
14Filename length (aligned to a multiple of 4)
Zero terminated filename, aligned to a word boundary will be written after the fixed size options.
15Extra information length
Zero terminated extra information, aligned to a word boundary will be written after the filename.
16File comment length
Zero terminated comment will be written after the extra information, and will be word aligned.
R1=Unzip handle
R2=pointer to output buffer
R3=number of objects to read
R4=opaque offset of object to start at, or 0 for first object
R5=length of output buffer
On exit
R3=number of objects read
R4=next opaque offset to use for enumerate
R5=size of unused data in output buffer
Interrupts
Interrupts are disabled
Fast interrupts are enabled
Processor mode
Processor is in SVC mode
Re-entrancy
SWI is not re-entrant
Use

This SWI is used to enumerate the objects in the archive. Data is written in the order given in the flags table above. The interface is intentionally similarly to OS_GBPB. This makes simple its use as a direct replacement for OS_GBPB.

Related SWIs
Zipper_UnZipOpen

Zipper_UnZipFileInfo
(SWI &559C4)

Read information on a file
On entry
R0=Flags
R1=Unzip handle
R2-3=See sub-reasons
On exit
None
Interrupts
Interrupts are disabled
Fast interrupts are enabled
Processor mode
Processor is in SVC mode
Re-entrancy
SWI is not re-entrant
Use

This SWI is used to read information on a single object. The call is available in two forms. The first form reads information on the object in the same manner as Enumerate. The second form reads information on the object in a similar manner to OS_File 5.

Related SWIs
Zipper_UnZipEnumerate

Zipper_UnZipFileInfo to buffer
(SWI &559C4)

Read information on a file to a buffer
On entry
R0=Flags :
Bit(s)Meaning
0-16Flags as Zipper_UnZipEnumerate
R1=Unzip handle
R2=pointer to filename to read
R3=pointer to buffer for data
R4=length of buffer
On exit
R3=pointer to end of data
R4=space remaining, or -ve length if data would not fit
Interrupts
Interrupts are disabled
Fast interrupts are enabled
Processor mode
Processor is in SVC mode
Re-entrancy
SWI is not re-entrant
Use

This SWI is used to read information on a object, using a similar interface to UnZipEnumerate.

Related SWIs
Zipper_UnZipEnumerate

Zipper_UnZipFileInfo to registers
(SWI &559C4)

Read information on a file to registers, like OS_File 5
On entry
R0=0 (no flags set)
R1=Unzip handle
R2=pointer to filename to read
On exit
R0=object type (1 = file, 2 = directory)
R2=load address
R3=exec address
R4=object length when decompressed
R5=file attributes
Interrupts
Interrupts are disabled
Fast interrupts are enabled
Processor mode
Processor is in SVC mode
Re-entrancy
SWI is not re-entrant
Use

This SWI is used to read information on a object, using a similar interface to OS_File 5.

Related SWIs
Zipper_UnZipEnumerate

Zipper_UnZipFileOpen
(SWI &559C5)

Open a file in an archive for input
On entry
R0=Flags (reserved, must be 0)
R1=Unzip handle
R2=Pointer to filename of file to read
On exit
None
Interrupts
Interrupts are disabled
Fast interrupts are enabled
Processor mode
Processor is in SVC mode
Re-entrancy
SWI is not re-entrant
Use

This SWI is used to open a file in an archive for reading.

Related SWIs
Zipper_UnZipFileClose

Zipper_UnZipFileClose
(SWI &559C6)

Close the current opened archive file
On entry
R0=Flags (reserved, must be 0)
R1=Unzip handle
On exit
None
Interrupts
Interrupts are disabled
Fast interrupts are enabled
Processor mode
Processor is in SVC mode
Re-entrancy
SWI is not re-entrant
Use

This SWI is used to close a file in an archive opened for reading. An error will be given if a CRC error was encountered.

Related SWIs
Zipper_UnZipFileOpen

Zipper_UnZipFileRead
(SWI &559C7)

Read data from a previously opened input archive
On entry
R0=Flags (reserved, must be 0)
R1=Unzip handle
R2=Pointer to buffer to write in to
R3=Length of buffer
On exit
R0=number of bytes read, or 0 if nothing could be read
Interrupts
Interrupts are disabled
Fast interrupts are enabled
Processor mode
Processor is in SVC mode
Re-entrancy
SWI is not re-entrant
Use

This SWI is used to read data from the currently opened file in the archive.

Related APIs
None

Zipper_UnZipFileEOF
(SWI &559C8)

Check whether end of file has been reached
On entry
R0=Flags (reserved, must be 0)
R1=Unzip handle
On exit
R0=1 if 'end of file', 0 if not.
Interrupts
Interrupts are disabled
Fast interrupts are enabled
Processor mode
Processor is in SVC mode
Re-entrancy
SWI is not re-entrant
Use

This SWI is used to discover whether the end of the currently opened file in the archive has been reached.

Related APIs
None

Zipper_ZipOpen
(SWI &559D0)

Create an archive
On entry
R0=Flags :
Bit(s)Meaning
0Append to file, rather than create file (for building self extracting archives
31If set, do not discard this archive handle when the application exits
1-30Reserved, must be 0
R1=Pointer to filename of archive to create or append to
On exit
R0=Opaque zip handle, guaranteed not to be 0
Interrupts
Interrupts are disabled
Fast interrupts are enabled
Processor mode
Processor is in SVC mode
Re-entrancy
SWI is not re-entrant
Use

This SWI opens a Zip archive for writing via the Zipper API. If the file cannot be opened, an error will be returned.

Related SWIs
Zipper_ZipClose

Zipper_ZipClose
(SWI &559D1)

Close a file, previously opened for writing
On entry
R0=Flags (reserved, must be 0)
R1=Zip handle
On exit
None
Interrupts
Interrupts are disabled
Fast interrupts are enabled
Processor mode
Processor is in SVC mode
Re-entrancy
SWI is not re-entrant
Use

This SWI is used to close an archive previously opened for writing.

Related SWIs
Zipper_ZipOpen

Zipper_ZipFileOpen
(SWI &559D2)

Open a file in an archive for input
On entry
R0=Flags :
Bit(s)Meaning
0Time specifier contains RISC OS details (otherwise it contains a Zip-style time specification)
1Object is a directory
2Object is text-like
3Extra field is present
4Comment field is present
5File attributes are present
R1=Zip handle
R2=Pointer to filename of file to write in archive
R3=Compression method and level :
Bit(s)Meaning
0-7Compression method :
ValueMeaning
0Store data as-is
8Apply deflate algorithm to compress data
otherUndefined
8-11Compression level :
ValueMeaning
1'Super fast, little compression'
2'Fast, more compression'
8'Normal speed, normal compression'
9'Slowest, maximum compression'
otherUndefined
12-31Reserved (must be zero)
R4=Pointer to time specifier block; if bit 0 set :
OffsetContents
+0Load address
+4Exec address
+8Attributes
If bit 0 clear :
OffsetContents
+0Centiseconds
+4Seconds
+8Minutes
+12Hours
+16Date
+20Month
+24Year
R5=Pointer to extra field data, if bit 3 set
R6=Length of extra field, if bit 3 set
R7=Pointer to zero terminated comment field, if bit 3 set
R8=Pointer to block of zip file attributes :
OffsetContents
+0internal file attributes
+4external file attributes
On exit
None
Interrupts
Interrupts are disabled
Fast interrupts are enabled
Processor mode
Processor is in SVC mode
Re-entrancy
SWI is not re-entrant
Use

This SWI is used to open a file in an archive for writing, or to create a directory.

Related SWIs
Zipper_ZipFileClose

Zipper_ZipFileClose
(SWI &559D3)

Close the current opened archive file
On entry
R0=Flags (reserved, must be 0)
R1=Zip handle
On exit
R0=Original (uncompressed) size of file
R1=New (compressed) size of file in archive
Interrupts
Interrupts are disabled
Fast interrupts are enabled
Processor mode
Processor is in SVC mode
Re-entrancy
SWI is not re-entrant
Use

This SWI is used to close a file in an archive opened for writing.

Related SWIs
Zipper_ZipFileOpen

Zipper_ZipFileWrite
(SWI &559D4)

Write data to a previously opened archive
On entry
R0=Flags (reserved, must be 0)
R1=Zip handle
R2=Pointer to buffer of data to write
R3=Length of buffer
On exit
None
Interrupts
Interrupts are disabled
Fast interrupts are enabled
Processor mode
Processor is in SVC mode
Re-entrancy
SWI is not re-entrant
Use

This SWI is used to write data to the currently opened file in the archive.

Related APIs
None

Document information

Maintainer(s): RISCOS Ltd <developer@riscos.com>
History:
RevisionDateAuthorChanges
1ROLInitial version
2GWTypos and gramatical check
  • Changed some of the wording to be clearer.
  • Corrected a few misspelt words.
3ROLAddition of ZipFileClose sizes
  • ZipFileClose now returns relative sizes of data.
Disclaimer:

Copyright © Pace Micro Technolgy plc, 2002.
Portions copyright © RISCOS Ltd, 2002.
Published by RISCOS Limited.
No part of this publication may be reproduced or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording or otherwise, or stored in any retrieval system of any nature, without the written permission of the copyright holder and the publisher, application for which shall be made to the publisher.