archivers/unzip.c
changeset 176 4a996749e39d
parent 148 5b95e3fa52d3
child 182 a47c39af46ad
--- a/archivers/unzip.c	Fri Apr 05 18:05:50 2002 +0000
+++ b/archivers/unzip.c	Fri Apr 05 18:07:18 2002 +0000
@@ -145,7 +145,7 @@
 	int *pi;
 {
     PHYSFS_uint8 c;
-	PHYSFS_sint64 err = __PHYSFS_platformRead(fin, &c, 1, 1);
+	PHYSFS_sint64 err = __PHYSFS_platformRead(fin, &c, sizeof (c), 1);
     if (err==1)
     {
         *pi = (int)c;
@@ -161,7 +161,6 @@
 }
 
 
-/* !!! FIXME: Use PhysFS byteswap routines. */
 /* ===========================================================================
    Reads a long in LSB order from the given gz_stream. Sets 
 */
@@ -169,57 +168,55 @@
 	void* fin;
     uLong *pX;
 {
-    uLong x ;
-    int i;
-    int err;
+    PHYSFS_uint16 val;
+	PHYSFS_sint64 err = __PHYSFS_platformRead(fin, &val, sizeof (val), 1);
+    if (err==1)
+    {
+        *pX = (uLong) PHYSFS_swapULE16(val);
+        return UNZ_OK;
+    }
+    else
+    {
+        *pX = 0;
+        if (__PHYSFS_platformEOF(fin)) 
+            return UNZ_EOF;
+        else
+            return UNZ_ERRNO;
+    }
 
-    err = unzlocal_getByte(fin,&i);
-    x = (uLong)i;
-    
-    if (err==UNZ_OK)
-        err = unzlocal_getByte(fin,&i);
-    x += ((uLong)i)<<8;
-   
-    if (err==UNZ_OK)
-        *pX = x;
-    else
-        *pX = 0;
-    return err;
+    return(UNZ_ERRNO);  /* shouldn't ever hit this. */
 }
 
-/* !!! FIXME: Use PhysFS byteswap routines. */
 local int unzlocal_getLong (fin,pX)
 	void* fin;
     uLong *pX;
 {
-    uLong x ;
-    int i;
-    int err;
-
-    err = unzlocal_getByte(fin,&i);
-    x = (uLong)i;
-    
-    if (err==UNZ_OK)
-        err = unzlocal_getByte(fin,&i);
-    x += ((uLong)i)<<8;
+    PHYSFS_uint32 val;
+	PHYSFS_sint64 err = __PHYSFS_platformRead(fin, &val, sizeof (val), 1);
+    if (err==1)
+    {
+        *pX = (uLong) PHYSFS_swapULE32(val);
+        return UNZ_OK;
+    }
+    else
+    {
+        *pX = 0;
+        if (__PHYSFS_platformEOF(fin)) 
+            return UNZ_EOF;
+        else
+            return UNZ_ERRNO;
+    }
 
-    if (err==UNZ_OK)
-        err = unzlocal_getByte(fin,&i);
-    x += ((uLong)i)<<16;
-
-    if (err==UNZ_OK)
-        err = unzlocal_getByte(fin,&i);
-    x += ((uLong)i)<<24;
-   
-    if (err==UNZ_OK)
-        *pX = x;
-    else
-        *pX = 0;
-    return err;
+    return(UNZ_ERRNO);  /* shouldn't ever hit this. */
 }
 
 
 /* My own strcmpi / strcasecmp */
+#if 1
+
+#define strcmpcasenosensitive_internal(x,y) __PHYSFS_platformStricmp(x,y)
+
+#else
 local int strcmpcasenosensitive_internal (fileName1,fileName2)
 	const char* fileName1;
 	const char* fileName2;
@@ -242,7 +239,7 @@
 			return 1;
 	}
 }
-
+#endif
 
 #ifdef  CASESENSITIVITYDEFAULT_NO
 #define CASESENSITIVITYDEFAULTVALUE 2