NAME
   ZIP - package and compress (archive) files

SYNOPSIS
   CHAIN "zip zipfile [inpath] [-# -D -g -nodir -q -r -resume -X]
 	[-i@includefile] [-pp path] [-S suffixfile] [-t date] [-quit quitcmd]"
    or   *zip zipfile [inpath] [-# -D -g -nodir -q -r -resume -X]
 	[-i@includefile] [-pp path] [-S suffixfile] [-t date] [-quit quitcmd]

DESCRIPTION
   zip is a compression and file packaging utility for Unix, VMS, MSDOS,
   OS/2, CP/M, Windows NT, Minix, Atari, Macintosh, Amiga, Acorn RISC OS
   and Acorn BBC.

   A companion program (unzip(1)), unpacks zip archives. The zip and
   unzip(1) programs can work with archives produced by PKZIP and
   Archive(1), and PKZIP, PKUNZIP and Archive can work with archives
   produced by zip. zip version 1.xx is compatible with PKZIP 2.04 and
   later and Archive 2.16 and later. Note that PKUNZIP 1.10 cannot extract
   files produced by PKZIP 2.04 or zip. You must use PKUNZIP 2.04g (or
   later versions) to extract them.

   The program is useful for packaging a set of files for distribution;
   for archiving files; and for saving disk space by temporarily
   compressing unused files or directories.

   This describes the BBC version of zip which aims to replicate the
   behaviour of InfoZip zip v3. It does not compress files, just archives
   them, unless helped by SparkFS.

ARGUMENTS
   zipfile
 	filename of the zipfile to create. The zipfile will be typed to
 	Archive (&DDC). On the Master and RISC OS the zipfile can have a
 	-fsname- or fsname: prefix to specify the filing system the file
 	is on.

   inpath
 	Path to include. If inpath is a directory, then all files
 	within that directory will be included. If inpath is a
 	file, just that single file will be included. If inpath
 	contains wildcards then it will use only the first matching
 	object.

OPTIONS
   Options supplied to the BBC version of zip must each be specified
   singly. This is different to other platforms where multiple options can
   be run together.

   -? 	Display the zip command line syntax.

   -D 	Do not create entries in the zip archive for directories.
 	Directory entries are created by default so that their
 	attributes can be saved in the zip archive.

   -g 	Grow existing zipfile by appending to it. If the existing
 	zipfile is truncated it will be appended to after the last
 	valid entry.

   -i@filename
 	Include the files listed in the file specified by filename.
 	If no filename is given, the filenames are read from the
 	input stream.

   -nodir
 	Do not add a zip catalogue to the end of the zipfile. The
 	final file only contains the stored entries with their
 	inline metadata. This will shorten the zipfile by something
 	like 10%-15% depending on contents, but some unzip tools
 	may not be able to extract the contents. BBC unzip does
 	extract the contents as it ignores the zip catalogue and
 	uses the inline metadata.

   -pp path
 	Prepends the specified path onto the stored filename in the
 	archive. This allows the entries within an archive to
 	appear to be within the specified directory. For example:

 	 	*zip outfile infile -pp DirName

 	will store infile in the archive, where it will be called
 	DirName.infile.

   -q 	Quiet mode. All output messages are disabled.

   -quit quitcmd
 	Command to execute on termination. This allows zip to be
 	called and then continue to a specified program. If quitcmd
 	starts with a '*' it is called as a *command, otherwise it
 	is CHAINed.

   -r 	Travel the directory structure recursively, for example:

 	 	*zip outfile indir -r

 	In this case, all the files and directories in indir are
 	saved in a zip archive named outfile.

   -resume
 	Restarts an aborted zip session by appending to the
 	zipfile, scanning through it and finding the last entry
 	successfully added and then continuing to add files from
 	that point onwards. This way an aborted zip session can be
 	restarted at the file that was being added when the
 	previous session terminated.

   -S suffixfile
 	Specifies a text file containing a list of file extensions
 	to map to file types, commonly called a MimeMap file. If
 	this is specified then files added to the zip file which
 	have truncated file extentions will have those extensions
 	extended according to their filetype. For instance, the
 	file mainpage/h will be stored as mainpage/htm (translated
 	to mainpage.htm) if it is filetyped to &FAF and the
 	suffixfile contains the entry 'FAF,htm'.

   -t date
 	Only include files that were modified on the specified date
 	or later. The date is specified as dd/mm/yyyy or yyyy/mm/dd.

   -X 	Include extra file information. By default zip stores a
 	object's load and execution address, access permissions,
 	and the modification date and time. This option will
 	include all the additional metadata associated with objects
 	stored on SJ MDFS file servers and with filing systems such
 	as HADFS, this being the creation date and time, main
 	account and auxillary acount.

   -# 	Specify the compression type used, where -0 is no
 	compression (store all files) and -8 is deflate. BBCZip
 	will compress files if used on RISC OS with SparkFS
 	running. Otherwise, any -# option is ignored and BBCZip
 	stores files. As a special option -255 causes zip to store
 	only objects' metadata and no data.

EXAMPLES
   The simplest example:

 	 	*zip stuff things

   creates the archive stuff and puts all the files in the directory
   things in it. This will not include any subdirectories from the
   directory. To do this, the command:

 	 	*zip stuff -r things

   creates the archive stuff, containing all the files and directories in
   directory things.

   The use of the -pp option allows the entries within the archive to be
   named as being in a specified directory. For example:

 	 	*zip BBCZip/zip BBCZip -r -pp Software.Archivers.BBCZip

   will archive the entries within the directory BBCZip and within the
   archive the entries will appear to be within a directory named
   Software.Archivers.BBCZip. Using this small parts of a directory tree
   can be archived without the whole directory tree having to be archived.

   The -i@ option allows a list of files in a textfile to be archived. 
   For example:

 	 	*zip Update/zip :Docs.$ -i@uplist

   will create the archive Update/zip containing only those files in
   directory :Docs.$ that are listed in the text file uplist. This option
   is useful when creating an update archive based on a comparison with
   another archive.

   The lines in the include file must be terminated with <cr>s. Note that
   there is no space between the '-i@' option and the filename.

   Using -@ with no filename will read the list of filenames from the
   current input stream. This can allow you to have an *EXEC file zip up
   objects from the EXEC file itself. For example, a file containing:

 	 	*zip ^.man/zip @ -@
 	 	man/src
 	 	man

   *EXECing this file will start zip and include the files in the current
   directory listed in the rest of the file.

   Using the -X option will include all the extra file information that
   systems such as the SJ MDFS fileserver have. Using:

 	 	*zip backup1 :SYSTEM.$ -r -X -pp :SYSTEM.$

   will create an archive of everything on the disk SYSTEM including all
   the additional file information, and including the name of the source
   directory in the archive entry names. This archive can be unzipped to
   completely restore all the files on disk SYSTEM along with all the
   associated file information using:

 	 	*unzip backup1 -X

   Note that to do this the appropriate user privileges will be required.

   The -t option gives the ability to make incremental zip archives,
   zipping up only files that have been modified after a certain date. As
   an example, extending the previous example to:

 	 	*zip backup1 :SYSTEM.$ -r -X -t 01/12/1999 -pp :SYSTEM.$

   would zip up only those files that were last modified on 1st December
   1999 or later.

   Note that you shouldn't try to create the zipfile within the directory
   structure that you specify to include in the zipfile otherwise zip will
   attempt to include the zipfile within itself. For example:

 	 	*zip stuff @

   will create the zipfile stuff within the current directory, and try to
   include within it all the files within the current directory, including
   the zipfile.

TECHNICAL INFORMATION
   ZIP files include an extras field that holds metadata specific to
   particular systems. Acorn metadata is stored in the extras field in the
   following format:

 	0  extra header id              2 bytes  "AC"
 	2  extra header sublength       2 bytes  ------------v
 	4  Acorn header id              4 bytes  "ARC0"      4
 	8  load address                 4 bytes              8
 	12  execution address            4 bytes             12
 	16  attributes                   4 bytes             16
 	20  &00000000                    4 bytes             20
 	24  creation time                2 bytes             22
 	26  creation date                2 bytes             24
 	28  main account number          2 bytes             26
 	30  auxilary account number      2 bytes             28

  Only that metadata specified by the header sublength is present. Any
  metadata that is omitted results in UnZip not setting that metadata on
  extracted objects. If the execution address is missing, but the load
  address is present, it is assumed to be the same as the load address.

  Creation and modification times and dates are stored in MS-DOS format.

  BBCZip bidirectionally swaps the following filename characters:
 	. <-> /    # <-> ?    $ <-> <    ^ <-> >    @ <-> =

  When appending with the -resume option BBCZip puts a "PK",&0F,&10
  'FileOpen' header at the start of the output file, followed by the
  offset to the last correctly-added entry. This allows the -resume
  option to quickly find the last entry. This header is replaced with a
  "PK",&03,&04 header when the file is finalised.

NOTES
   zip 1.xx does not compress files, just stores.

  The -X switch is slightly non-symetrical between Zip and UnZip:
 	Zip      stores just the common Acorn metadata, load/exec addresses,
 	 	attributes and modification date/time
 	Zip -X   stores all available metadata on the source filing system
 	UnZip    extracts all stored metadata except any account numbers
 	UnZip -X extracts all stored metadata and any account numbers

   If running in an environment where SparkFS is available, then
   compression is available by calling *ZipCompress.

   zip attempts to find additional file metadata by using OSFILE &FD,
   NetFS_Op 18,64 and NetFS_Op 18,65.

   There is a bug in the CmdLine library used by zip where any hyphen is
   seen as introducing an option, for example Zip -ramfs-out or Zip new-run
   is seen as the -r option. This can be worked around by using upper
   case for the file name, eg -RAMFS-out or a colon filing system
   prefix, eg ramfs:out.

   Need to do:
 	Some way of storing metadata on start directory, so zip out $ -r
 	stores infomation about $.
 	Store 'P' bit from MDFS
 	Is DefAccess info readable from MDFS?

SEE ALSO
   Archive(1), UnZip(1), UnZip(9), Zip(1), Zip(5), Zip(9), ZipCat(1),
   ZipDiff(1), ZipEx(1), ZipInfo(1).

AUTHOR
   J.G.Harston <jgh@mdfs.net>