Fixed Windows/PocketPC __PHYSFS_platformEOF() for zero-length files. stable-2.0
authorRyan C. Gordon <icculus@icculus.org>
Mon, 01 Aug 2011 17:37:06 -0400
branchstable-2.0
changeset 1175 e55bbdb69dfd
parent 1172 1a5ccd9dc5a0
child 1178 dec7e09cb3d9
Fixed Windows/PocketPC __PHYSFS_platformEOF() for zero-length files.
platform/pocketpc.c
platform/windows.c
--- a/platform/pocketpc.c	Sat Jul 16 14:14:00 2011 +0000
+++ b/platform/pocketpc.c	Mon Aug 01 17:37:06 2011 -0400
@@ -505,14 +505,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/windows.c	Sat Jul 16 14:14:00 2011 +0000
+++ b/platform/windows.c	Mon Aug 01 17:37:06 2011 -0400
@@ -1182,14 +1182,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);