Diffstat (limited to 'noncore/apps/opie-reader/pdb.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-reader/pdb.cpp | 38 |
1 files changed, 34 insertions, 4 deletions
diff --git a/noncore/apps/opie-reader/pdb.cpp b/noncore/apps/opie-reader/pdb.cpp index dca67ff..39551cc 100644 --- a/noncore/apps/opie-reader/pdb.cpp +++ b/noncore/apps/opie-reader/pdb.cpp @@ -1,13 +1,37 @@ #include "pdb.h" #ifdef _WINDOWS #include <winsock2.h> #endif +#include "useqpe.h" + +#ifdef USEQPE +void Cpdb::suspend() +{ + CExpander::suspend(fin); +} +void Cpdb::unsuspend() +{ + CExpander::unsuspend(fin); +} +#endif + +Cpdb::~Cpdb() +{ + if (fin != NULL) + { +#ifdef USEQPE + unsuspend(); +#endif + fclose(fin); + } +} + size_t Cpdb::recordpos(int n) { UInt16 mxn = ntohs(head.recordList.numRecords); if (n >= mxn) { return file_length; } else @@ -27,34 +51,40 @@ size_t Cpdb::recordlength(int n) return recordpos(n+1)-recordpos(n); } void Cpdb::gotorecordnumber(int n) { fseek(fin, recordpos(n), SEEK_SET); } -bool Cpdb::openfile(const char *src) +bool Cpdb::openpdbfile(const char *src) { + //qDebug("cpdb openfile:%s", src); // printf("In openfile\n"); - int ret = 0; // printf("closing fin:%x\n",fin); if (fin != NULL) fclose(fin); // printf("opening fin\n"); fin = fopen(src,"rb"); if (fin==0) { return false; } // just holds the first few chars of the file // char buf[0x100]; - fseek(fin,0,SEEK_END); - file_length = ftell(fin); + struct stat _stat; + stat(src,&_stat); + file_length = _stat.st_size; + // fseek(fin,0,SEEK_END); + // file_length = ftell(fin); fseek(fin,0,SEEK_SET); fread(&head, 1, sizeof(head), fin); + qDebug("Database name:%s", head.name); + qDebug("Total number of records:%u", ntohs(head.recordList.numRecords)); + return true; } |