archivers/grp.c
changeset 163 fc2b8ee5b420
parent 161 4fcc863fdc5f
child 175 45e423c38ff8
equal deleted inserted replaced
162:06ed1dc94f73 163:fc2b8ee5b420
   128 {
   128 {
   129     GRPfileinfo *finfo = (GRPfileinfo *) (handle->opaque);
   129     GRPfileinfo *finfo = (GRPfileinfo *) (handle->opaque);
   130     void *fh = finfo->handle;
   130     void *fh = finfo->handle;
   131     PHYSFS_sint64 curPos = __PHYSFS_platformTell(fh);
   131     PHYSFS_sint64 curPos = __PHYSFS_platformTell(fh);
   132     PHYSFS_uint64 bytesLeft = (finfo->startPos + finfo->size) - curPos;
   132     PHYSFS_uint64 bytesLeft = (finfo->startPos + finfo->size) - curPos;
   133     /*!!! If objSize is '1' it's quite likely that objsLeft will be greater than 32-bits */
   133     PHYSFS_uint64 objsLeft = (bytesLeft / objSize);
   134     PHYSFS_uint32 objsLeft = (PHYSFS_uint32)(bytesLeft / objSize);
       
   135 
   134 
   136     if (objsLeft < objCount)
   135     if (objsLeft < objCount)
   137         objCount = objsLeft;
   136         objCount = objsLeft;
   138 
   137 
   139     return(__PHYSFS_platformRead(fh, buffer, objSize, objCount));
   138     return(__PHYSFS_platformRead(fh, buffer, objSize, objCount));
   156 
   155 
   157 
   156 
   158 static int GRP_seek(FileHandle *handle, PHYSFS_uint64 offset)
   157 static int GRP_seek(FileHandle *handle, PHYSFS_uint64 offset)
   159 {
   158 {
   160     GRPfileinfo *finfo = (GRPfileinfo *) (handle->opaque);
   159     GRPfileinfo *finfo = (GRPfileinfo *) (handle->opaque);
   161     /*!!! Why isn't newPos a 64-bit??? */
   160     PHYSFS_uint64 newPos = (finfo->startPos + offset);
   162     int newPos = (int)(finfo->startPos + offset);
       
   163 
   161 
   164     BAIL_IF_MACRO(offset < 0, ERR_INVALID_ARGUMENT, 0);
   162     BAIL_IF_MACRO(offset < 0, ERR_INVALID_ARGUMENT, 0);
   165     BAIL_IF_MACRO(newPos > finfo->startPos + finfo->size, ERR_PAST_EOF, 0);
   163     BAIL_IF_MACRO(newPos > finfo->startPos + finfo->size, ERR_PAST_EOF, 0);
   166     return(__PHYSFS_platformSeek(finfo->handle, newPos));
   164     return(__PHYSFS_platformSeek(finfo->handle, newPos));
   167 } /* GRP_seek */
   165 } /* GRP_seek */
   287                                             int omitSymLinks)
   285                                             int omitSymLinks)
   288 {
   286 {
   289     PHYSFS_uint8 buf[16];
   287     PHYSFS_uint8 buf[16];
   290     GRPinfo *g = (GRPinfo *) (h->opaque);
   288     GRPinfo *g = (GRPinfo *) (h->opaque);
   291     void *fh = g->handle;
   289     void *fh = g->handle;
   292     /*!!! This should be a uint32 and not an int...look at loops below */
       
   293     PHYSFS_uint32 i;
   290     PHYSFS_uint32 i;
   294     LinkedStringList *retval = NULL;
   291     LinkedStringList *retval = NULL;
   295     LinkedStringList *l = NULL;
   292     LinkedStringList *l = NULL;
   296     LinkedStringList *prev = NULL;
   293     LinkedStringList *prev = NULL;
   297 
   294 
   300         return(NULL);
   297         return(NULL);
   301 
   298 
   302         /* jump to first file entry... */
   299         /* jump to first file entry... */
   303     BAIL_IF_MACRO(!__PHYSFS_platformSeek(fh, 16), NULL, NULL);
   300     BAIL_IF_MACRO(!__PHYSFS_platformSeek(fh, 16), NULL, NULL);
   304 
   301 
   305     /*!!! i needs to be unsigned */
       
   306     for (i = 0; i < g->totalEntries; i++)
   302     for (i = 0; i < g->totalEntries; i++)
   307     {
   303     {
   308         BAIL_IF_MACRO(__PHYSFS_platformRead(fh, buf, 16, 1) != 1, NULL, retval);
   304         BAIL_IF_MACRO(__PHYSFS_platformRead(fh, buf, 16, 1) != 1, NULL, retval);
   309 
   305 
   310         buf[12] = '\0';  /* FILENAME.EXT is all you get. */
   306         buf[12] = '\0';  /* FILENAME.EXT is all you get. */
   339                                   PHYSFS_uint32 *size)
   335                                   PHYSFS_uint32 *size)
   340 {
   336 {
   341     PHYSFS_uint8 buf[16];
   337     PHYSFS_uint8 buf[16];
   342     GRPinfo *g = (GRPinfo *) (h->opaque);
   338     GRPinfo *g = (GRPinfo *) (h->opaque);
   343     void *fh = g->handle;
   339     void *fh = g->handle;
   344     /*!!! This should be a uint32 and not an int...look at loops below */
       
   345     PHYSFS_uint32 i;
   340     PHYSFS_uint32 i;
   346     char *ptr;
   341     char *ptr;
   347     int retval = (g->totalEntries + 1) * 16; /* offset of raw file data */
   342     int retval = (g->totalEntries + 1) * 16; /* offset of raw file data */
   348 
   343 
   349     /* Rule out filenames to avoid unneeded file i/o... */
   344     /* Rule out filenames to avoid unneeded file i/o... */