Quellcode durchsuchen

Fixed Windows/PocketPC __PHYSFS_platformEOF() for zero-length files.
(transplanted from e55bbdb69dfd9771a5222b6a406a9c418ffbe53b)

Ryan C. Gordon vor 14 Jahren
Ursprung
Commit
1921be0ddf
2 geänderte Dateien mit 10 neuen und 2 gelöschten Zeilen
  1. 5 1
      platform/pocketpc.c
  2. 5 1
      platform/win32.c

+ 5 - 1
platform/pocketpc.c

@@ -591,14 +591,18 @@ PHYSFS_sint64 __PHYSFS_platformFileLength(void *opaque)
 
 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);

+ 5 - 1
platform/win32.c

@@ -936,14 +936,18 @@ PHYSFS_sint64 __PHYSFS_platformFileLength(void *opaque)
 
 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);