Diffstat (limited to 'noncore/apps/opie-reader/pdb.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-reader/pdb.cpp | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/noncore/apps/opie-reader/pdb.cpp b/noncore/apps/opie-reader/pdb.cpp index 3054424..dca67ff 100644 --- a/noncore/apps/opie-reader/pdb.cpp +++ b/noncore/apps/opie-reader/pdb.cpp | |||
@@ -1,16 +1,16 @@ | |||
1 | #include "pdb.h" | 1 | #include "pdb.h" |
2 | #include <sys/types.h> | 2 | #ifdef _WINDOWS |
3 | #include <sys/stat.h> | 3 | #include <winsock2.h> |
4 | #include <unistd.h> | 4 | #endif |
5 | 5 | ||
6 | size_t Cpdb::recordpos(int n) | 6 | size_t Cpdb::recordpos(int n) |
7 | { | 7 | { |
8 | UInt16 mxn = ntohs(head.recordList.numRecords); | 8 | UInt16 mxn = ntohs(head.recordList.numRecords); |
9 | if (n >= mxn) | 9 | if (n >= mxn) |
10 | { | 10 | { |
11 | return file_length; | 11 | return file_length; |
12 | } | 12 | } |
13 | else | 13 | else |
14 | { | 14 | { |
15 | size_t dataoffset = sizeof(DatabaseHdrType) - sizeof(UInt16); | 15 | size_t dataoffset = sizeof(DatabaseHdrType) - sizeof(UInt16); |
16 | dataoffset += /*dataoffset%4 + */ sizeof(RecordListType) * n; | 16 | dataoffset += /*dataoffset%4 + */ sizeof(RecordListType) * n; |
@@ -40,24 +40,21 @@ bool Cpdb::openfile(const char *src) | |||
40 | // printf("closing fin:%x\n",fin); | 40 | // printf("closing fin:%x\n",fin); |
41 | if (fin != NULL) fclose(fin); | 41 | if (fin != NULL) fclose(fin); |
42 | // printf("opening fin\n"); | 42 | // printf("opening fin\n"); |
43 | fin = fopen(src,"rb"); | 43 | fin = fopen(src,"rb"); |
44 | 44 | ||
45 | if (fin==0) | 45 | if (fin==0) |
46 | { | 46 | { |
47 | return false; | 47 | return false; |
48 | } | 48 | } |
49 | 49 | ||
50 | // just holds the first few chars of the file | 50 | // just holds the first few chars of the file |
51 | //char buf[0x100]; | 51 | //char buf[0x100]; |
52 | struct stat buf; | 52 | fseek(fin,0,SEEK_END); |
53 | stat(src, &buf); | 53 | file_length = ftell(fin); |
54 | file_length = buf.st_size; | ||
55 | // fseek(fin,0,SEEK_END); | ||
56 | // file_length = ftell(fin); | ||
57 | 54 | ||
58 | // fseek(fin,0,SEEK_SET); | 55 | fseek(fin,0,SEEK_SET); |
59 | 56 | ||
60 | fread(&head, 1, sizeof(head), fin); | 57 | fread(&head, 1, sizeof(head), fin); |
61 | 58 | ||
62 | return true; | 59 | return true; |
63 | } | 60 | } |