GZip File Reading

Stewart Gordon smjg_1998 at yahoo.com
Fri Mar 11 16:12:06 PST 2011


On 10/03/2011 04:53, dsimcha wrote:
<snip>
> 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.

You don't seem to get how std.stream works.

The API is defined in the InputStream and OutputStream interfaces.  Various classes 
implement this interface, generally through the Stream abstract class, to provide the 
functionality for a specific kind of stream.  File is just one of these classes.  Another 
is MemoryStream, to read to and write from a buffer in memory.  A stream class used to 
work with gzipped files would be just another.

Indeed, we have FilterStream, which is a base class for stream classes that wrap a stream, 
such as a file or memory stream, to modify the data in some way as it goes in and out. 
Compressing or decompressing is an example of this - so I guess that GzipStream would be a 
subclass of FilterStream.

Stewart.


More information about the Digitalmars-d mailing list