BBCZip 1.35/1.12 ================ J.G.Harston 1999-2017 mdfs.net/Apps/Archivers/BBCZip - jgh@mdfs.net 70 Camm Street, Walkley, Sheffield S6 3TR Introduction ------------ ZIP archiving is probably the most common method of archiving files, and one of the most common methods of file compression. BBCZip consists of programs that allow you to create, extract and examine ZIP archives. They have been written to use InfoZip command line parameters. The BASIC programs will also run on RISC OS systems. The supplied programs are UnZip, Zip, ZipCat, ZipDiff, ZipEx and ZipInfo. They perform the following actions: UnZip - Extracts stored files from a ZIP file Zip - Creates ZIP file, storing files ZipCat - Lists the contents of a Zip file ZipEx - Lists the contents of a Zip file with info like *Ex ZipInfo - Displays detailed info on Zip file contents ZipDiff - Compares a zip archive with a filesystem The distribution also includes the manual entries for the commands in the ManPages directory which contains full documentation. Brief usage details ------------------- CHAIN "zip zipfile indir [options]" or *zip zipfile indir [options] -? Display the zip command line syntax. -D Do not create entries for directories. -g Grow existing zipfile by appending to it. -help Display long help information. -i@filename Include the files listed in filename. -M size Maximum file transfer buffer size. -nodir Do not add a zip catalogue. -pp path Prepends the specified path onto stored filenames. -q Quiet mode. -quit cmd Command to execute on termination. -r Travel the directory structure recursively. -resume Restarts an aborted zip session. -S file File containing file extensions to map to file types. -t date Only include files modified on or later then date. -v Set verbosity level, -v1 is single line. -X Include all extra file metadata. -# Compression type to used, default is -0 for no compression. -255 Create 'envelope' only containg file metadata. CHAIN "unzip zipfile [options]" or *unzip zipfile [options] -? Display the unzip command line syntax. -d exdir Directory into which files will be extracted. -help Display long help information. -q Quiet mode. -quit cmd Command to execute on termination. -X Set user accounts. -255 Only extract file metadata. When running on the Master series or RISC OS the zipfile filename can use both RISC OS style filing system prefix and Master style, for example "zip -ramfs-outfile" or "unzip ramfs:infile". More detailed usage information is in the Manual pages. Other platforms --------------- The only format currently supported is stored ZIP, that is uncompressed files. If used on RISC OS BBCZip can compress and uncompress files if SparkFS is running. There are various ways to create ZIP files with stored data on other systems. Check the documentation for your ZIP creation program, looking for something like 'Options: No Compression' or 'Compression: Stored'. As an example, using PKWare's PKZip program or InfoZip's Zip program, using the following command: PKZIP -e0 -p name.zip file or InfoZip name.zip file -0 will make a ZIP file called "name.zip" and puts a stored copy of "file" in it. Using: PKZIP -e0 -p -r name.zip dir\*.* or InfoZip name.zip dir\*.* -0 -r will create a ZIP archive called "name.zip" containing stored copies of all the files in directory "dir" and all of the contents of its subdirectories. Technical Details ----------------- A ZIP file consists of a series of entries in the following format: local file header signature 4 bytes "PK",&03,&04 version needed to extract 2 bytes general purpose bit flag 2 bytes compression method 2 bytes last modification time 2 bytes last modification date 2 bytes crc-32 4 bytes compressed size 4 bytes uncompressed size 4 bytes filename length 2 bytes extra field length 2 bytes filename (variable size) extra field (variable size) data (variable size) Acorn metadata is stored in the extra field in the following format: extra header id 2 bytes "AC" extra header sublength 2 bytes ------------v Acorn header id 4 bytes "ARC0" 4 load address 4 bytes 8 execution address 4 bytes 12 attributes 4 bytes 16 &00000000 4 bytes 20 creation time 2 bytes 22 creation date 2 bytes 24 main account number 2 bytes 26 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: / <-> . ? <-> # $ <-> < ^ <-> > @ <-> = & <-> + % <-> ; On extracting, BBCUnZip converts spaces in filenames to underlines. Compatability ------------- BBCZip has been tested and works on BBC B, Electron, Master, Compact, RISC OS, DFS, ADFS, HADFS, NFS, 6502Tube, Z80Tube, ARMTube. There is a bug in the command-line parsing 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 is a bug in the CmdLine library. Use upper case for the file name, eg "zip -RAMFS-out" or use RISC OS style paths, eg "zip ramfs:out". Initial versions of UnZip were based on Sprow's UnZip. Version History --------------- *Zip 1.00 06-Jun-1999 Initial version, no CRCs 1.01 01-Sep-1999 Calculates CRCs (very slowly!) 1.02 04-Sep-1999 Writes catalogue at end 1.03 12-Sep-1999 CRCs correct, manually calculated 1.10 28-Sep-1999 Uses mcode to calculate CRCs 1.11 28-Sep-1999 Parses command line 1.12 02-Oct-1999 -a option done (only MDFS, no 'P' yet) 1.13 20-Oct-1999 -t option done, -a is now -X 1.14 28-Oct-1999 Manually calculates CRCs on non-6502 1.15 08-Mar-2000 Display on zero-length files ok 1.16 12-Mar-2000 CRC code for Arc (Z80 next) 1.17 18-Jul-2000 Arc can call SparkFS to do compression 1.18 31-Jul-2000 -# -D done, ARM CRC code corrected 1.19 20-Sep-2000 -# allows >9, -255 creates envelopes 1.20 20-Oct-2000 Added -i@file, and -nodir options 1.24 15-Dec-2002 Better InitZip 1.25 12-Jan-2003 Doesn't crunch small files 1.26 15-Sep-2005 Workaround to avoid a bug in raFS, fixed long date handling. 1.27 28-Mar-2007 Updated ProgEnv for ARM CoPro 1.28 07-Jan-2011 Added -g, -S, -resume options, -p renamed to -pp. 1.29 12-Jan-2011 start$ correctly set to last good entry, not first bad entry 1.30 15-Mar-2011 Split into modules, updated NetFS code 1.31 28-May-2011 BGET/BPUT replaced with OSGBPB, general tidying up. 1.32 08-Jun-2011 Faster CRC, faster OSGBPB, -v1 tidied up, extra CRC optimisation by Greg Cook. 1.33 22-Jun-2011 Fuller pathname translation. 1.34 16-Jan-2014 -resume puts 'StillOpen' flag in output file to skip directly to last entry, skips source directories. 1.35 15-Oct-2017 fsname: -> -fsname-, optimised FNfn_zip(), crunched CRC code *UnZip 1.00 06-Jun-1999 Loosely based on Sprow's UnZip, ignores CRCs 1.01 16-Jun-1999 Reads command line 1.02 22-Jun-1999 Dosifies filenames 1.03 17-Jul-1999 Fuller implementation, -X option 1.04 20-Nov-2000 -q quiet mode 1.06 28-Dec-2000 Inflate on RISC OS 1.07 22-Mar-2001 Sets mdate/time, cdate/time on SJ and HADFS 1.08 17-Jun-2001 Split into modules 1.09 12-Jan-2002 Tweeked attribute setting 1.10 22-Jun-2011 Fuller pathname translation. 1.11 30-Sep-2017 Bugfix ensuring output file writeable on ADFS 1.12 15-Oct-2017 fsname: -> -fsname-, optimised FNfn_zip() *ZipCat/*ZipEx 0.10 30-Nov-1999 Initial version 0.11 01-Dec-1999 Ignores absent extras fields, better name display 0.12 12-Jan-2011 Full filename character translation, viz #?$<^> *ZipInfo 1.00 06-Jun-1999 Initial version 1.01 10-Jan-2005 Seconds displayed correctly 1.02 12-Jan-2011 Updated GetEnv, full filename character translation 1.03 23-Sep-2011 Displays full Acorn info *ZipDiff 1.00 23-Jan-2002 Initial version 1.01 26-Mar-2002 Doesn't preserve zptr, adds if meta different 1.02 26-Mar-2002 Disabled since-date checking 1.03 24-Jul-2002 No output to delfile, doesn't scan for dels, /ZI matches /ZIP etc 1.04 17-Nov-2002 Tried and get comparison working properly 1.05 25-Nov-2002 Doesn't compare ATTRs 1.06 20-Jan-2003 Needs: Select what to compare