summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-reader/ZText.h
Side-by-side diff
Diffstat (limited to 'noncore/apps/opie-reader/ZText.h') (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/opie-reader/ZText.h39
1 files changed, 35 insertions, 4 deletions
diff --git a/noncore/apps/opie-reader/ZText.h b/noncore/apps/opie-reader/ZText.h
index ab81a5e..06e3bf8 100644
--- a/noncore/apps/opie-reader/ZText.h
+++ b/noncore/apps/opie-reader/ZText.h
@@ -14,4 +14,6 @@ public:
{
#ifdef USEQPE
+ if (!bSuspended)
+ {
bSuspended = true;
suspos = gztell(file);
@@ -19,4 +21,5 @@ public:
file = NULL;
sustime = time(NULL);
+ }
#endif
}
@@ -27,6 +30,9 @@ public:
{
bSuspended = false;
+ if (sustime != ((time_t)-1))
+ {
int delay = time(NULL) - sustime;
if (delay < 10) sleep(10-delay);
+ }
file = gzopen(fname, "rb");
for (int i = 0; file == NULL && i < 5; i++)
@@ -47,5 +53,11 @@ public:
virtual ~Text()
{
- if (file != NULL) gzclose(file);
+ if (file != NULL)
+ {
+#ifdef USEQPE
+ unsuspend();
+#endif
+ gzclose(file);
+ }
}
int OpenFile(const char *src)
@@ -57,7 +69,25 @@ public:
return ((file = gzopen(src,"rb")) == NULL);
}
- int getch() { return gzgetc(file); }
- unsigned int locate() { return gztell(file); }
- void locate(unsigned int n) { gzseek(file,n,SEEK_SET); }
+ int getch()
+ {
+#ifdef USEQPE
+ unsuspend();
+#endif
+ return gzgetc(file);
+ }
+ unsigned int locate()
+ {
+#ifdef USEQPE
+ unsuspend();
+#endif
+ return gztell(file);
+ }
+ void locate(unsigned int n)
+ {
+#ifdef USEQPE
+ unsuspend();
+#endif
+ gzseek(file,n,SEEK_SET);
+ }
bool hasrandomaccess() { return true; }
void sizes(unsigned long& _file, unsigned long& _text)
@@ -82,4 +112,5 @@ public:
return cTEXT;
}
+ QString about() { return QString("Text/gzipped text codec (c) Tim Wentford"); }
};
#endif