[Gambas-devel] Zlib

Benoit Minisini gambas at ...1...
Tue Feb 17 21:27:46 CET 2004


On Tuesday 17 February 2004 20:21, Daniel Campos wrote:
> Hi:
>
> I'm at 'network' hollydays now, so I'm writting a ZLIB wrapper
> ( http://www.gzip.org/zlib ) to relax a little.
>
> By now, it has a class 'ZStream' to allow read and write from
> gzippez files directly as if it were usual files.
>
> I can not use 'OPEN' stream method by now, as it does not accept
> my object as a valid 'FILE?', but the rest of streams methods
> works.
>
> Once you untar this file, copy 'zlib' folder to {gambas sources}/src/lib
> , then copy attacheed configure.in to replace current gambas
> configure.in, type ./reconf, and ./configure with your usual
> options, go to {gambas sources}/src/lib/zlib, do 'make' and 'make
> install'.
>
> You have also a very little example at zlib/example
>
> Regards,
>
> Daniel Campos

Actually, OPEN has no hooks. It can only create buffered, direct or "archive" 
streams (i.e. stream that read file stored in a project executable). It 
decides what kind of stream it creates by analyzing the path 
(relative/absolute) and the keyword DIRECT.

The (*open) field is the STREAM structure is used by the OPEN command only in 
these cases!

To open your "zlib" stream, the user will have to instanciate the class you 
created, as he had to with Socket streams.

DIM hFile AS CompressedFile
hFile = NEW CompressedFile("/home/gambas/source.gz", "rw", 9)

In the future, we could imagine an URL-based OPEN, and that stream types will 
register under an URL protocol. Something like OPEN 
"gzip:/home/gambas/source.gz" FOR READ or OPEN "/home/gambas/source.gz" 
PROTOCOL "gzip" FOR READ. 

But I prefer when you instanciate streams. And you can add parameters to the 
stream constructor! For example, the compression rate for the zlib.

Or OPEN could get a stream type to create the appropriate stream. This will be 
intelligent!

DIM hFile AS CompressedFile
OPEN CompressedFile "/home/benoit/source.gz" FOR CREATE AS hFile

I prefer the last soultion finally :-)

What do you think ?

Regards,

-- 
Benoit Minisini
mailto:gambas at ...1...





More information about the Devel mailing list