ZIP File System aDr.SlumpProduction1998-9
Official documentation v0.1b (3-March-1999)
Spanish version by Iván Montes Velencoso a.k.a Dr.Slump/Fearminds
English translation by Dr.Slump
Current ZFS version 1.0b3


INTRODUCTION

Zip File System allows you to access to the contents of any ZIP file in an easy and fast way. One of its main characteristics, is that frees the programmer of the hard task of uncompress a file for use it. With ZFS doesn't exist any difference between access to a compressed and packed file in a ZIP and do it in a normally stored file in a directory of the disk.

This simplicity of handling for the compressed files doesn't mean any lose of freedom for the programmer, but this allows a faster development of an application that needs to use a big amount of files. For example, if you are programming a game you can do all the development without compress the pictures and when you do the final version you can pack and compress all the files in one or several ZIP files and the program will continue working well without do any modification. It's great!


LICENSE OF USE

The author, this is me, doesn't get any responsibility for any hurt that this software could do

Probably I could use the GNU license to distribute this library, but from my point of view is unnecessary to use a so large license for a simple, although awesome, library. So I've created my own license :

ZIP File System or ZFS is copyright of Fearminds Productions. This software can be distributed freely as well as no money is earn with this. Including this library in recopilatory cd-roms or any other way of free distribution (www, ftp ...) is allowed too.

If you use this software you must put the name of the author in the credits and if you can send me a copy of the program or tell me where I can get it.

If you make any improvements in the library you should send me it to add it to the next official release of the library.

If you make a commercial application of any type with ZFS, you must send me a full free copy of it and give a 2% of the profits to a non governmental organization like GreenPeace, Caritas, Unicez ...


WHERE TO GET IT

The official distribution is for the moment at :

My homepage, http://members.tripod.com/imontes/
X2FTP, ftp://x2ftp.oulu.fi/pub/msdos/programming/

I hope to add it to some anonymous ftps


HOW TO CONTACT WITH THE AUTHOR

You can contact with me throw this ways :

Email : drslump@axis.org

WWW : http://members.tripod.com/imontes/

Snail Mail :

FearMinds Productions
Edison, 48
zip: 08812, Les Roquetes
Barcelona, Spain


DOCUMENTATION


With this library you can access to packed and compressed files in ZIP format as easily as if they were normally stored on the disk. This is possible thanks to the design of this library that re-implements the standard Pascal file routines (assign, reset, close, blockread ....), in this way is incredibly easy to create applications with ZFS. Take this in mind, ZFS never writes in the disk, it only read from the disk and perform all the operations in memory so you can use it perfectly in a read only device like a cdrom.

The library use is as simple that this document is nearly unnecessary, but there are some things to have in mind if you want to optimize your application. For a more advanced information on this topic take a look at the "limitation" section of below.

To use this library you only have to add it to the Uses section of the program and in every unit that make use of the file routines. In example if we have a unit to load the graphics, we have to include ZFS in the Uses section of this unit to allow that the loading routines recognize the compressed file.

Unit LoadGFX;

Interface
...
Implementation
Uses ZFS;
...
end.
Program TEST001;

Uses Crt, LoadGFX, ZFS;

...


end.

Once that we have included ZFS in our program only rest tell to the system what ZIP files are necessary. To do that we use the routine OpenZIP(ZIPname :string; mode :Boolean) that will return a pointer of type pZip with the information of the zip file.
The routine OpenZip allows two modes of initialization. The first threats the files of the Zip as if they were in the program directory, it's the called NormalMode. The second, called DirMode, threats the files as if they were in a sub directory with the name of the Zip file. For example, if the zip file is called GFX.ZIP the files of it will be placed in a sub directory called GFX.

When we open a file, ZFS will search on the disk that file, if it's not found ZFS will search inside the opened Zip files. If you open first GFX.ZIP and after SOUND.ZIP the system will search the files first at the disk, after at GFX.ZIP and finally at SOUND.ZIP. I hope this have been well understood because it could give some bugs hard to find.

It's ready!, once we have opened the Zip files we only have to operate like we always do to access at the disk files. I encourage you to have a look at the limitations section to avoid errors and at the tricks and tips section for a better optimization of the code. If after all that you have yet any doubt study the examples or send me an e-mail, I will try to answer your questions.


LIMITATIONS


Due to the design of the system the access to compressed files is much slower than to stored files. When you access to a packed uncompressed file the speed is more or less the same that if you access to a file normally stored on the disk.

In the current version, although I'm working on it, you can't do a seek directly in a compressed file. This is a really big problem because if we have a file of 64000 bytes compressed and we want to seek it at its 32000 bytes, the system will uncompress the first 32000 bytes and after it returned the second 32000 bytes. So we are really uncompressing 64000 bytes although we only need 32000.

Another limitation of this system is that is not possible to use files of type text compressed or packed in a Zip. This is due to the threat that Pascal routines do of this type of files and for lack of time I haven't implement the routines needed to support them. Although the ZFS can't handle text files you can continue using them if they are stored normally at disk.

And another one. The way of open a typed file (f : file of "type";) is a bit different from the pascal RTL. ZFS can't know about the size of the type used in the file, so you have to tell it as a second parameter. Look at this example :

Uses ZFS;
type
tRec = RECORD
a,b,c :Longint;
end;

var f: file of tRec;
begin
assign(f, 'TEST.REC');
reset(f, sizeof(tRec));
close(f);
end.
{In pascal it will be Reset(f);}


TRICKS AND TIPS

-The ZFS needs about 60Kb of memory for temporal buffers.

-You can't use the routines of file writing (Rewrite, BlockWrite, Write) with packed files. If you do that the system will return an IO error. Remember a ZIP is threat as a read-only device.

-Try to don't use compressed files too big, because you can't access to them randomly. Always you can read all the needed information at once.



LAST WORDS

I would like to thanks to Christian Ghisler, Mark Adler, Dr Abimbola Olowofoyeku and Peter Vreman for the Pascal conversion of the INFO-ZIP's Unzip library.


Copyright Iván Montes Velencoso a.k.a Dr.Slump/Fearminds, 3-3-1999