Fixed Windows/PocketPC __PHYSFS_platformEOF() for zero-length files. stable-1.0
authorRyan C. Gordon <icculus@icculus.org>
Mon, 01 Aug 2011 17:37:06 -0400
branchstable-1.0
changeset 1177 05a842260409
parent 1166 c3212f7b8a52
child 1179 eea580b4e199
Fixed Windows/PocketPC __PHYSFS_platformEOF() for zero-length files. (transplanted from e55bbdb69dfd9771a5222b6a406a9c418ffbe53b)
platform/pocketpc.c
platform/win32.c
--- a/platform/pocketpc.c	Wed Jun 01 03:16:15 2011 -0400
+++ b/platform/pocketpc.c	Mon Aug 01 17:37:06 2011 -0400
@@ -591,14 +591,18 @@
 
 int __PHYSFS_platformEOF(void *opaque)
 {
+    const PHYSFS_sint64 FileLength = __PHYSFS_platformFileLength(opaque);
     PHYSFS_sint64 FilePosition;
     int retval = 0;
 
+    if (FileLength == 0)
+        return 1;  /* we're definitely at EOF. */
+
     /* Get the current position in the file */
     if ((FilePosition = __PHYSFS_platformTell(opaque)) != 0)
     {
         /* Non-zero if EOF is equal to the file length */
-        retval = FilePosition == __PHYSFS_platformFileLength(opaque);
+        retval = (FilePosition == FileLength);
     } /* if */
 
     return(retval);
--- a/platform/win32.c	Wed Jun 01 03:16:15 2011 -0400
+++ b/platform/win32.c	Mon Aug 01 17:37:06 2011 -0400
@@ -936,14 +936,18 @@
 
 int __PHYSFS_platformEOF(void *opaque)
 {
+    const PHYSFS_sint64 FileLength = __PHYSFS_platformFileLength(opaque);
     PHYSFS_sint64 FilePosition;
     int retval = 0;
 
+    if (FileLength == 0)
+        return 1;  /* we're definitely at EOF. */
+
     /* Get the current position in the file */
     if ((FilePosition = __PHYSFS_platformTell(opaque)) != 0)
     {
         /* Non-zero if EOF is equal to the file length */
-        retval = FilePosition == __PHYSFS_platformFileLength(opaque);
+        retval = (FilePosition == FileLength);
     } /* if */
 
     return(retval);