summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-reader/Text.h
Unidiff
Diffstat (limited to 'noncore/apps/opie-reader/Text.h') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-reader/Text.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/noncore/apps/opie-reader/Text.h b/noncore/apps/opie-reader/Text.h
new file mode 100644
index 0000000..4c689be
--- a/dev/null
+++ b/noncore/apps/opie-reader/Text.h
@@ -0,0 +1,28 @@
1#ifndef __Text_h
2#define __Text_h
3#include <stdio.h>
4#include <sys/stat.h>
5#include "CExpander.h"
6
7class Text: public CExpander {
8 FILE* file;
9public:
10 Text() : file(NULL) {};
11 virtual ~Text() { if (file != NULL) fclose(file); }
12 virtual int openfile(const tchar *src)
13 {
14 if (file != NULL) fclose(file);
15 return ((file = fopen(src,"rb")) == NULL);
16 }
17 virtual int getch() { return fgetc(file); }
18 virtual unsigned int locate() { return ftell(file); }
19 virtual void locate(unsigned int n) { fseek(file,n,SEEK_SET); }
20 virtual bool hasrandomaccess() { return true; }
21 virtual void sizes(unsigned long& _file, unsigned long& _text)
22 {
23 struct stat _stat;
24 fstat(fileno(file),&_stat);
25 _text = _file = _stat.st_size;
26 }
27};
28#endif