ソースを参照

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

Ryan C. Gordon 14 年 前
コミット
a7d5c1d3cd
2 ファイル変更10 行追加2 行削除
  1. 5 1
      platform/pocketpc.c
  2. 5 1
      platform/windows.c

+ 5 - 1
platform/pocketpc.c

@@ -505,14 +505,18 @@ PHYSFS_sint64 __PHYSFS_platformFileLength(void *opaque)
 
 
 int __PHYSFS_platformEOF(void *opaque)
 int __PHYSFS_platformEOF(void *opaque)
 {
 {
+    const PHYSFS_sint64 FileLength = __PHYSFS_platformFileLength(opaque);
     PHYSFS_sint64 FilePosition;
     PHYSFS_sint64 FilePosition;
     int retval = 0;
     int retval = 0;
 
 
+    if (FileLength == 0)
+        return 1;  /* we're definitely at EOF. */
+
     /* Get the current position in the file */
     /* Get the current position in the file */
     if ((FilePosition = __PHYSFS_platformTell(opaque)) != 0)
     if ((FilePosition = __PHYSFS_platformTell(opaque)) != 0)
     {
     {
         /* Non-zero if EOF is equal to the file length */
         /* Non-zero if EOF is equal to the file length */
-        retval = FilePosition == __PHYSFS_platformFileLength(opaque);
+        retval = (FilePosition == FileLength);
     } /* if */
     } /* if */
 
 
     return(retval);
     return(retval);

+ 5 - 1
platform/windows.c

@@ -1182,14 +1182,18 @@ PHYSFS_sint64 __PHYSFS_platformFileLength(void *opaque)
 
 
 int __PHYSFS_platformEOF(void *opaque)
 int __PHYSFS_platformEOF(void *opaque)
 {
 {
+    const PHYSFS_sint64 FileLength = __PHYSFS_platformFileLength(opaque);
     PHYSFS_sint64 FilePosition;
     PHYSFS_sint64 FilePosition;
     int retval = 0;
     int retval = 0;
 
 
+    if (FileLength == 0)
+        return 1;  /* we're definitely at EOF. */
+
     /* Get the current position in the file */
     /* Get the current position in the file */
     if ((FilePosition = __PHYSFS_platformTell(opaque)) != 0)
     if ((FilePosition = __PHYSFS_platformTell(opaque)) != 0)
     {
     {
         /* Non-zero if EOF is equal to the file length */
         /* Non-zero if EOF is equal to the file length */
-        retval = FilePosition == __PHYSFS_platformFileLength(opaque);
+        retval = (FilePosition == FileLength);
     } /* if */
     } /* if */
 
 
     return(retval);
     return(retval);