]>
Commit | Line | Data |
---|---|---|
5bb88929 CW |
1 | /* |
2 | * Copyright (c) 2008, Charles Wilson | |
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 Charles Wilson <cygwin@cygwin.com> | |
13 | * | |
14 | */ | |
15 | ||
16 | #ifndef SETUP_COMPRESS_LZMA_H | |
17 | #define SETUP_COMPRESS_LZMA_H | |
18 | ||
19 | /* this is the parent class for all compress IO operations. | |
20 | */ | |
21 | ||
22 | #include "compress.h" | |
23 | #include "lzma-sdk/LzmaDec.h" | |
24 | ||
25 | class compress_lzma:public compress | |
26 | { | |
27 | public: | |
28 | compress_lzma (io_stream *); /* decompress (read) only */ | |
29 | virtual ssize_t read (void *buffer, size_t len); | |
30 | virtual ssize_t write (const void *buffer, size_t len); /* not implemented */ | |
31 | virtual ssize_t peek (void *buffer, size_t len); | |
32 | virtual long tell (); /* not implemented */ | |
33 | virtual int seek (long where, io_stream_seek_t whence); /* not implemented */ | |
34 | virtual int error (); | |
35 | virtual const char *next_file_name () { return NULL; }; | |
26922cd2 | 36 | virtual int set_mtime (time_t); |
b41c2908 CV |
37 | virtual time_t get_mtime (); |
38 | virtual mode_t get_mode (); | |
5bb88929 CW |
39 | virtual size_t get_size () {return 0;}; |
40 | virtual ~compress_lzma (); | |
41 | static bool is_lzma(void *buffer, size_t len); | |
42 | virtual void release_original(); /* give up ownership of original io_stream */ | |
43 | ||
44 | private: | |
45 | compress_lzma () {}; | |
46 | ||
47 | io_stream *original; | |
48 | bool owns_original; | |
49 | char peekbuf[512]; | |
50 | size_t peeklen; | |
51 | int lasterr; | |
52 | bool initializedOk; | |
53 | void check_header (); | |
54 | void destroy (); | |
55 | ||
56 | /* from lzma */ | |
57 | static const size_t IN_BUF_SIZE = (1 << 16); | |
58 | static const size_t OUT_BUF_SIZE = (1 << 16); | |
59 | unsigned char header[LZMA_PROPS_SIZE + 8]; | |
60 | UInt64 unpackSize; | |
61 | bool thereIsSize; /* true means header specifies uncompressed size */ | |
62 | CLzmaDec state; | |
63 | unsigned char * inbuf; | |
64 | unsigned char * outbuf; | |
65 | unsigned char * outp; | |
66 | size_t inPos; | |
67 | size_t inSize; | |
68 | size_t outPos; | |
69 | SizeT inProcessed; | |
70 | SizeT outProcessed; | |
71 | }; | |
72 | ||
73 | #endif /* SETUP_COMPRESS_LZMA_H */ |