big file support
[pandora-libraries.git] / lib / pnd_discovery.c
index 76f2868..1e465ff 100644 (file)
@@ -75,7 +75,7 @@ static int pnd_disco_callback ( const char *fpath, const struct stat *sb,
   pnd_pxml_handle pxmlh = 0;
   pnd_pxml_handle *pxmlapps = NULL;
   pnd_pxml_handle *pxmlappiter;
   pnd_pxml_handle pxmlh = 0;
   pnd_pxml_handle *pxmlapps = NULL;
   pnd_pxml_handle *pxmlappiter;
-  unsigned int pxml_close_pos = 0;
+  off_t pxml_close_pos = 0;
   unsigned char logit = pnd_log_do_buried_logging();
 
   if ( logit ) {
   unsigned char logit = pnd_log_do_buried_logging();
 
   if ( logit ) {
@@ -154,7 +154,7 @@ static int pnd_disco_callback ( const char *fpath, const struct stat *sb,
       pngbuffer [ 4 ] = 13;       pngbuffer [ 5 ] = 10;       pngbuffer [ 6 ] = 26;      pngbuffer [ 7 ] = 10;
 
       unsigned char padtests = 20;
       pngbuffer [ 4 ] = 13;       pngbuffer [ 5 ] = 10;       pngbuffer [ 6 ] = 26;      pngbuffer [ 7 ] = 10;
 
       unsigned char padtests = 20;
-      unsigned int padstart = ftell ( f );
+      off_t padstart = ftello ( f );
 
       // seek back 10 (should be back into the /PXML> part) to catch any appending-icon-no-line-endings funny business
       fseek ( f, -10, SEEK_CUR );
 
       // seek back 10 (should be back into the /PXML> part) to catch any appending-icon-no-line-endings funny business
       fseek ( f, -10, SEEK_CUR );
@@ -163,7 +163,7 @@ static int pnd_disco_callback ( const char *fpath, const struct stat *sb,
 
        if ( fread ( pngbuffer + 8, 8, 1, f ) == 1 ) {
          if ( memcmp ( pngbuffer, pngbuffer + 8, 8 ) == 0 ) {
 
        if ( fread ( pngbuffer + 8, 8, 1, f ) == 1 ) {
          if ( memcmp ( pngbuffer, pngbuffer + 8, 8 ) == 0 ) {
-           pxml_close_pos = ftell ( f ) - 8;
+           pxml_close_pos = ftello ( f ) - 8;
            break;
          } // if
          fseek ( f, -7, SEEK_CUR ); // seek back 7 (so we're 1 further than we started, since PNG header is 8b)
            break;
          } // if
          fseek ( f, -7, SEEK_CUR ); // seek back 7 (so we're 1 further than we started, since PNG header is 8b)
@@ -174,7 +174,7 @@ static int pnd_disco_callback ( const char *fpath, const struct stat *sb,
 
       if ( ! padtests ) {
        // no icon found, so back to where we started looking
 
       if ( ! padtests ) {
        // no icon found, so back to where we started looking
-       fseek ( f, padstart, SEEK_SET );
+       fseeko ( f, padstart, SEEK_SET );
       }
 
     } // icon
       }
 
     } // icon
@@ -234,7 +234,12 @@ static int pnd_disco_callback ( const char *fpath, const struct stat *sb,
       p -> subapp_number = ((pnd_pxml_t*) pxmlh) -> subapp_number;
 
       // png icon path
       p -> subapp_number = ((pnd_pxml_t*) pxmlh) -> subapp_number;
 
       // png icon path
+      p -> pnd_icon_pos64 = pxml_close_pos;
       p -> pnd_icon_pos = pxml_close_pos;
       p -> pnd_icon_pos = pxml_close_pos;
+      if ( (off_t) p -> pnd_icon_pos != pxml_close_pos ) {
+        // pnd_icon_pos is an int and the offset doesn't fit, bad luck...
+        p -> pnd_icon_pos = 0;
+      }
 
       // type
       p -> object_type = valid;
 
       // type
       p -> object_type = valid;