equal
deleted
inserted
replaced
332 |
332 |
333 static int grp_load_entries(const char *name, int forWriting, GRPinfo *info) |
333 static int grp_load_entries(const char *name, int forWriting, GRPinfo *info) |
334 { |
334 { |
335 void *fh = NULL; |
335 void *fh = NULL; |
336 PHYSFS_uint32 fileCount; |
336 PHYSFS_uint32 fileCount; |
337 PHYSFS_uint32 location = 32; /* sizeof sig + sizeof 1st file header. */ |
337 PHYSFS_uint32 location = 16; /* sizeof sig. */ |
338 GRPentry *entry; |
338 GRPentry *entry; |
339 char *ptr; |
339 char *ptr; |
340 |
340 |
341 BAIL_IF_MACRO(!grp_open(name, forWriting, &fh, &fileCount), NULL, 0); |
341 BAIL_IF_MACRO(!grp_open(name, forWriting, &fh, &fileCount), NULL, 0); |
342 info->entryCount = fileCount; |
342 info->entryCount = fileCount; |
344 if (info->entries == NULL) |
344 if (info->entries == NULL) |
345 { |
345 { |
346 __PHYSFS_platformClose(fh); |
346 __PHYSFS_platformClose(fh); |
347 BAIL_MACRO(ERR_OUT_OF_MEMORY, 0); |
347 BAIL_MACRO(ERR_OUT_OF_MEMORY, 0); |
348 } /* if */ |
348 } /* if */ |
|
349 |
|
350 location += (16 * fileCount); |
349 |
351 |
350 for (entry = info->entries; fileCount > 0; fileCount--, entry++) |
352 for (entry = info->entries; fileCount > 0; fileCount--, entry++) |
351 { |
353 { |
352 if (__PHYSFS_platformRead(fh, &entry->name, 12, 1) != 1) |
354 if (__PHYSFS_platformRead(fh, &entry->name, 12, 1) != 1) |
353 { |
355 { |
365 return(0); |
367 return(0); |
366 } /* if */ |
368 } /* if */ |
367 |
369 |
368 entry->size = PHYSFS_swapULE32(entry->size); |
370 entry->size = PHYSFS_swapULE32(entry->size); |
369 entry->startPos = location; |
371 entry->startPos = location; |
370 location += entry->size + 16; |
372 location += entry->size; |
371 } /* for */ |
373 } /* for */ |
372 |
374 |
373 __PHYSFS_platformClose(fh); |
375 __PHYSFS_platformClose(fh); |
374 |
376 |
375 grp_sort_entries(info->entries, info->entryCount); |
377 grp_sort_entries(info->entries, info->entryCount); |