GZip File Reading

Russel Winder russel at russel.org.uk
Thu Mar 10 02:17:17 PST 2011


On Wed, 2011-03-09 at 23:53 -0500, dsimcha wrote:
> I noticed last night that Phobos actually has all the machinations 
> required for reading gzipped files, buried in etc.c.zlib.  I've wanted a 
> high-level D interface for reading and writing compressed files with an 
> API similar to "normal" file I/O for a while.  I'm thinking about what 
> the easiest/best design would be.  At a high level there are two designs:

But isn't a gzip (or zip, 7z, bzip2, etc., etc.) file actually a
container:  a tree of files.  So isn't it more a persistent data
structure that has a rendering as a single flat file on the filestore,
than being a partitioned flat file which is what you will end up with if
you head directly down the file/stream route? 

> 1.  Hack std.stdio.file to support gzipped formats.  This would allow an 
> identical interface for "normal" and compressed I/O.  It would also 
> allow reuse of things like ByLine.  However, it would require major 
> refactoring of File to decouple it from the C file I/O routines so that 
> it could call either the C or GZip ones depending on how it's 
> configured.  Probably, it would make sense to make an interface that 
> wraps I/O functions and make an instance for C and one for gzip, with 
> bzip2 and other goodies possibly being added later.
> 
> 2.  Write something completely separate.  This would keep std.stdio.File 
> doing one thing well (wrapping C file I/O) but would be more of a PITA 
> for the user and possibly result in code duplication.
> 
> I'd like to get some comments on what an appropriate API design and 
> implementation for writing gzipped files would be.  Two key requirements 
> are that it must be as easy to use as std.stdio.File and it must be easy 
> to extend to support other single-file compression formats like bz2.

-- 
Russel.
=============================================================================
Dr Russel Winder      t: +44 20 7585 2200   voip: sip:russel.winder at ekiga.net
41 Buckmaster Road    m: +44 7770 465 077   xmpp: russel at russel.org.uk
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20110310/ef98bc70/attachment.pgp>


More information about the Digitalmars-d mailing list