]> cygwin.com Git - cygwin-apps/setup.git/blame - compress_bz.h
2004-12-26 Max Bowsher <maxb@ukf.net>
[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
c93bc6d0
MB
16#ifndef SETUP_COMPRESS_BZ_H
17#define SETUP_COMPRESS_BZ_H
b24c88b3
RC
18
19/* this is the bz2 class for all compressed IO operations.
20 */
21
22#ifdef _WIN32
23#undef _WIN32
37decc22
RC
24/* If we are going to hide the fact that we are _WIN32 from bzlib,
25 + then we need to #undef small for it as well (bad windows.h clash). */
26#undef small
db04fc41 27#include <bzlib.h>
b24c88b3 28#define _WIN32
37decc22 29/* What do we redefine small as? - RBC */
b24c88b3 30#else
db04fc41 31#include <bzlib.h>
b24c88b3
RC
32#endif
33
34class compress_bz:public compress
35{
36public:
37 /* assumes decompression */
38 compress_bz (io_stream *);
39 /* allows comp/decomp but this implementation only handles comp */
40 compress_bz (io_stream *, const char *);
41 /* read data (duh!) */
42 virtual ssize_t read (void *buffer, size_t len);
43 /* provide data to (double duh!) */
ca9506cc 44 virtual ssize_t write (const void *buffer, size_t len);
b24c88b3
RC
45 /* read data without removing it from the class's internal buffer */
46 virtual ssize_t peek (void *buffer, size_t len);
47 virtual long tell ();
ca9506cc 48 virtual int seek (long where, io_stream_seek_t whence);
b24c88b3
RC
49 /* try guessing this one */
50 virtual int error ();
51 /* Find out the next stream name -
52 * ie for foo.tar.bz, at offset 0, next_file_name = foo.tar
53 * for foobar that is an compress, next_file_name is the next
54 * extractable filename.
55 */
56 virtual const char *next_file_name ()
57 {
58 return NULL;
59 };
60 virtual int set_mtime (int);
341988b9
RC
61 /* Use seek EOF, then tell (). get_size won't do this incase you are sucking dow
62 * over a WAN :} */
63 virtual size_t get_size () {return 0;};
b24c88b3
RC
64 virtual int get_mtime ();
65 /* if you are still needing these hints... give up now! */
66 virtual ~ compress_bz ();
67private:
68 io_stream *original;
69 char peekbuf[512];
70 size_t peeklen;
71 int lasterr;
72 bz_stream strm;
73 int initialisedOk;
74 int bufN;
75 char buf[4096];
76 int writing;
387cb501 77 size_t position;
b24c88b3
RC
78};
79
c93bc6d0 80#endif /* SETUP_COMPRESS_BZ_H */
This page took 0.041332 seconds and 5 git commands to generate.