src/archiver_wad.c
changeset 1203 55f147714ce2
parent 1129 d81afe4b0a97
child 1240 22d4d1bd4e21
--- a/src/archiver_wad.c	Fri Mar 09 03:55:23 2012 -0500
+++ b/src/archiver_wad.c	Fri Mar 09 04:50:27 2012 -0500
@@ -47,19 +47,13 @@
 #define __PHYSICSFS_INTERNAL__
 #include "physfs_internal.h"
 
-static inline int readAll(PHYSFS_Io *io, void *buf, const PHYSFS_uint64 len)
-{
-    return (io->read(io, buf, len) == len);
-} /* readAll */
-
-
 static UNPKentry *wadLoadEntries(PHYSFS_Io *io, PHYSFS_uint32 fileCount)
 {
     PHYSFS_uint32 directoryOffset;
     UNPKentry *entries = NULL;
     UNPKentry *entry = NULL;
 
-    BAIL_IF_MACRO(!readAll(io, &directoryOffset, 4), NULL, 0);
+    BAIL_IF_MACRO(!__PHYSFS_readAll(io, &directoryOffset, 4), NULL, 0);
     directoryOffset = PHYSFS_swapULE32(directoryOffset);
 
     BAIL_IF_MACRO(!io->seek(io, directoryOffset), NULL, 0);
@@ -69,9 +63,9 @@
 
     for (entry = entries; fileCount > 0; fileCount--, entry++)
     {
-        GOTO_IF_MACRO(!readAll(io, &entry->startPos, 4), NULL, wadLoad_failed);
-        GOTO_IF_MACRO(!readAll(io, &entry->size, 4), NULL, wadLoad_failed);
-        GOTO_IF_MACRO(!readAll(io, &entry->name, 8), NULL, wadLoad_failed);
+        GOTO_IF_MACRO(!__PHYSFS_readAll(io, &entry->startPos, 4), NULL, failed);
+        GOTO_IF_MACRO(!__PHYSFS_readAll(io, &entry->size, 4), NULL, failed);
+        GOTO_IF_MACRO(!__PHYSFS_readAll(io, &entry->name, 8), NULL, failed);
 
         entry->name[8] = '\0'; /* name might not be null-terminated in file. */
         entry->size = PHYSFS_swapULE32(entry->size);
@@ -80,7 +74,7 @@
 
     return entries;
 
-wadLoad_failed:
+failed:
     allocator.Free(entries);
     return NULL;
 } /* wadLoadEntries */
@@ -90,21 +84,21 @@
 {
     PHYSFS_uint8 buf[4];
     UNPKentry *entries = NULL;
-    PHYSFS_uint32 entryCount = 0;
+    PHYSFS_uint32 count = 0;
 
     assert(io != NULL);  /* shouldn't ever happen. */
 
     BAIL_IF_MACRO(forWriting, ERR_ARC_IS_READ_ONLY, 0);
-    BAIL_IF_MACRO(!readAll(io, buf, sizeof (buf)), NULL, NULL);
+    BAIL_IF_MACRO(!__PHYSFS_readAll(io, buf, sizeof (buf)), NULL, NULL);
     if ((memcmp(buf, "IWAD", 4) != 0) && (memcmp(buf, "PWAD", 4) != 0))
         BAIL_MACRO(ERR_NOT_AN_ARCHIVE, NULL);
 
-    BAIL_IF_MACRO(!readAll(io, &entryCount, sizeof (entryCount)), NULL, NULL);
-    entryCount = PHYSFS_swapULE32(entryCount);
+    BAIL_IF_MACRO(!__PHYSFS_readAll(io, &count, sizeof (count)), NULL, NULL);
+    count = PHYSFS_swapULE32(count);
 
-    entries = wadLoadEntries(io, entryCount);
+    entries = wadLoadEntries(io, count);
     BAIL_IF_MACRO(entries == NULL, NULL, NULL);
-    return UNPK_openArchive(io, entries, entryCount);
+    return UNPK_openArchive(io, entries, count);
 } /* WAD_openArchive */