2 * Copyright (c) 2001, Robert Collins.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * A copy of the GNU General Public License can be found at
12 * Written by Robert Collins <rbtcollins@hotmail.com>
16 #ifndef SETUP_COMPRESS_H
17 #define SETUP_COMPRESS_H
19 #include "io_stream.h"
21 class compress
:public io_stream
24 /* Get a decompressed stream from a normal stream. If this function returns non-null
25 * a valid compress header was found. The io_stream pointer passed to decompress
26 * should be discarded. The old io_stream will be automatically closed when the
27 * decompression stream is closed
29 static io_stream
*decompress (io_stream
*);
31 * To create a stream that will be compressed, you should open the url, and then get a new stream
32 * from compress::compress.
34 /* read data (duh!) */
35 virtual ssize_t
read (void *buffer
, size_t len
) = 0;
36 /* provide data to (double duh!) */
37 virtual ssize_t
write (const void *buffer
, size_t len
) = 0;
38 /* read data without removing it from the class's internal buffer */
39 virtual ssize_t
peek (void *buffer
, size_t len
) = 0;
40 virtual off_t
tell () = 0;
41 /* try guessing this one */
42 virtual int error () = 0;
43 /* Find out the next stream name -
44 * ie for foo.tar.gz, at offset 0, next_file_name = foo.tar
45 * for foobar that is an compress, next_file_name is the next
46 * extractable filename.
48 virtual const char *next_file_name () = 0;
49 /* if you are still needing these hints... give up now! */
50 virtual ~compress () = 0;
53 #endif /* SETUP_COMPRESS_H */