big file support
[pandora-libraries.git] / lib / pnd_pndfiles.c
index 3200442..bdef6a6 100644 (file)
@@ -17,8 +17,8 @@
 unsigned char pnd_pnd_seek_pxml ( FILE *f ) {
   char *b;                // buffer
   char *match;            // match within buffer
-  unsigned int len;       // length of file (not suporting 'big files' 2GB..)
-  unsigned int pos;       // current tape head
+  off_t len;              // length of file (supporting 'big files' 2GB+)
+  off_t pos;              // current tape head
   unsigned int readable;  // amount to read (for small files/chunks)
 
   b = malloc ( PND_PXML_WINDOW_SIZE + 1 );
@@ -30,9 +30,9 @@ unsigned char pnd_pnd_seek_pxml ( FILE *f ) {
   memset ( b, '\0', PND_PXML_WINDOW_SIZE + 1 );
 
   // determine length of file
-  fseek ( f, 0, SEEK_END );
-  len = ftell ( f );
-  fseek ( f, 0, SEEK_SET );
+  fseeko ( f, 0, SEEK_END );
+  len = ftello ( f );
+  fseeko ( f, 0, SEEK_SET );
 
   /* ready to scan through the file, backwards
    */
@@ -51,7 +51,7 @@ unsigned char pnd_pnd_seek_pxml ( FILE *f ) {
     //printf ( "find pxml; pos %u readable %u\n", pos, readable );
 
     // seek into this blocks position
-    fseek ( f, pos, SEEK_SET );
+    fseeko ( f, pos, SEEK_SET );
 
     // read
     fread ( b, 1, readable, f );
@@ -60,7 +60,7 @@ unsigned char pnd_pnd_seek_pxml ( FILE *f ) {
     // strings within an arbitrary buffer. Thats needs to be done. This is the worst
     // performing brute force strategy here.
     if ( ( match = pnd_match_binbuf ( b, readable, PXML_TAGHEAD ) ) ) {
-      fseek ( f, pos + ( match - b ), SEEK_SET );
+      fseeko ( f, pos + ( match - b ), SEEK_SET );
       //printf ( "  match found at %u\n", pos + ( match - b ) );
       free ( b );
       return ( 1 );