summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-reader/ZText.h
blob: 2848af733e1e8874439917c79eb34db163036bed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#ifndef __Text_h
#define __Text_h
#include <stdio.h>
#include <zlib.h>
#include <sys/stat.h>

#include "CExpander.h"

class Text: public CExpander {
  gzFile file;
  unsigned long fsize;
public:
  Text() : file(NULL) {};
  virtual ~Text()
    {
      if (file != NULL) gzclose(file);
    }
  virtual int openfile(const char *src)
    {
      if (file != NULL) gzclose(file);
      struct stat _stat;
      stat(src,&_stat);
      fsize = _stat.st_size;
      return ((file = gzopen(src,"rb")) == NULL);
    }
  virtual int getch() { return gzgetc(file); }
  virtual unsigned int locate() { return gztell(file); }
  virtual void locate(unsigned int n) { gzseek(file,n,SEEK_SET); }
  virtual bool hasrandomaccess() { return true; }
  virtual void sizes(unsigned long& _file, unsigned long& _text)
    {
      _text = _file = fsize;
    }
};
#endif