]> cygwin.com Git - cygwin-apps/setup.git/blob - compress_bz.h
2002-05-11 Robert Collins <rbtcollins@hotmail.com>
[cygwin-apps/setup.git] / compress_bz.h
1 /*
2 * Copyright (c) 2001, Robert Collins.
3 *
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.
8 *
9 * A copy of the GNU General Public License can be found at
10 * http://www.gnu.org/
11 *
12 * Written by Robert Collins <rbtcollins@hotmail.com>
13 *
14 */
15
16 #ifndef _COMPRESS_BZ_H_
17 #define _COMPRESS_BZ_H_
18
19 /* this is the bz2 class for all compressed IO operations.
20 */
21
22 #ifdef _WIN32
23 #undef _WIN32
24 #include <bzlib.h>
25 #define _WIN32
26 #else
27 #include <bzlib.h>
28 #endif
29
30 class compress_bz:public compress
31 {
32 public:
33 /* assumes decompression */
34 compress_bz (io_stream *);
35 /* allows comp/decomp but this implementation only handles comp */
36 compress_bz (io_stream *, const char *);
37 /* read data (duh!) */
38 virtual ssize_t read (void *buffer, size_t len);
39 /* provide data to (double duh!) */
40 virtual ssize_t write (const void *buffer, size_t len);
41 /* read data without removing it from the class's internal buffer */
42 virtual ssize_t peek (void *buffer, size_t len);
43 virtual long tell ();
44 virtual int seek (long where, io_stream_seek_t whence);
45 /* try guessing this one */
46 virtual int error ();
47 /* Find out the next stream name -
48 * ie for foo.tar.bz, at offset 0, next_file_name = foo.tar
49 * for foobar that is an compress, next_file_name is the next
50 * extractable filename.
51 */
52 virtual const char *next_file_name ()
53 {
54 return NULL;
55 };
56 virtual int set_mtime (int);
57 /* Use seek EOF, then tell (). get_size won't do this incase you are sucking dow
58 * over a WAN :} */
59 virtual size_t get_size () {return 0;};
60 virtual int get_mtime ();
61 /* if you are still needing these hints... give up now! */
62 virtual ~ compress_bz ();
63 private:
64 io_stream *original;
65 char peekbuf[512];
66 size_t peeklen;
67 int lasterr;
68 bz_stream strm;
69 int initialisedOk;
70 int bufN;
71 char buf[4096];
72 int writing;
73
74 };
75
76 #endif /* _COMPRESS_BZ_H_ */
This page took 0.03754 seconds and 5 git commands to generate.