author | llornkcor <llornkcor> | 2002-07-01 23:24:08 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-07-01 23:24:08 (UTC) |
commit | 59222a752fa4c8a1e8c2a00ee2f9e22855f12bb2 (patch) (unidiff) | |
tree | f148d4858859dac3b413e675c760acfdab24b8e6 /noncore/apps/opie-reader/ZText.h | |
parent | c08be8ae22dcc1bfb83cfdec807149b161d770f5 (diff) | |
download | opie-59222a752fa4c8a1e8c2a00ee2f9e22855f12bb2.zip opie-59222a752fa4c8a1e8c2a00ee2f9e22855f12bb2.tar.gz opie-59222a752fa4c8a1e8c2a00ee2f9e22855f12bb2.tar.bz2 |
initial
Diffstat (limited to 'noncore/apps/opie-reader/ZText.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-reader/ZText.h | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/noncore/apps/opie-reader/ZText.h b/noncore/apps/opie-reader/ZText.h new file mode 100644 index 0000000..2848af7 --- a/dev/null +++ b/noncore/apps/opie-reader/ZText.h | |||
@@ -0,0 +1,35 @@ | |||
1 | #ifndef __Text_h | ||
2 | #define __Text_h | ||
3 | #include <stdio.h> | ||
4 | #include <zlib.h> | ||
5 | #include <sys/stat.h> | ||
6 | |||
7 | #include "CExpander.h" | ||
8 | |||
9 | class Text: public CExpander { | ||
10 | gzFile file; | ||
11 | unsigned long fsize; | ||
12 | public: | ||
13 | Text() : file(NULL) {}; | ||
14 | virtual ~Text() | ||
15 | { | ||
16 | if (file != NULL) gzclose(file); | ||
17 | } | ||
18 | virtual int openfile(const char *src) | ||
19 | { | ||
20 | if (file != NULL) gzclose(file); | ||
21 | struct stat _stat; | ||
22 | stat(src,&_stat); | ||
23 | fsize = _stat.st_size; | ||
24 | return ((file = gzopen(src,"rb")) == NULL); | ||
25 | } | ||
26 | virtual int getch() { return gzgetc(file); } | ||
27 | virtual unsigned int locate() { return gztell(file); } | ||
28 | virtual void locate(unsigned int n) { gzseek(file,n,SEEK_SET); } | ||
29 | virtual bool hasrandomaccess() { return true; } | ||
30 | virtual void sizes(unsigned long& _file, unsigned long& _text) | ||
31 | { | ||
32 | _text = _file = fsize; | ||
33 | } | ||
34 | }; | ||
35 | #endif | ||