]> cygwin.com Git - cygwin-apps/setup.git/blame - compress_bz.h
2002-11-10 Robert Collins <rbtcollins@hotmail.com>
[cygwin-apps/setup.git] / compress_bz.h
CommitLineData
b24c88b3
RC
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
db04fc41 24#include <bzlib.h>
b24c88b3
RC
25#define _WIN32
26#else
db04fc41 27#include <bzlib.h>
b24c88b3
RC
28#endif
29
30class compress_bz:public compress
31{
32public:
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!) */
ca9506cc 40 virtual ssize_t write (const void *buffer, size_t len);
b24c88b3
RC
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 ();
ca9506cc 44 virtual int seek (long where, io_stream_seek_t whence);
b24c88b3
RC
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);
341988b9
RC
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;};
b24c88b3
RC
60 virtual int get_mtime ();
61 /* if you are still needing these hints... give up now! */
62 virtual ~ compress_bz ();
63private:
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;
387cb501 73 size_t position;
b24c88b3
RC
74};
75
76#endif /* _COMPRESS_BZ_H_ */
This page took 0.033722 seconds and 5 git commands to generate.