From a7d5c1d3cd0e92ea0d1d882f47ff4c4809c0fda9 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Mon, 1 Aug 2011 17:37:06 -0400 Subject: [PATCH] Fixed Windows/PocketPC __PHYSFS_platformEOF() for zero-length files. --- platform/pocketpc.c | 6 +++++- platform/windows.c | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/platform/pocketpc.c b/platform/pocketpc.c index 15137fc8..5c5d7f20 100644 --- a/platform/pocketpc.c +++ b/platform/pocketpc.c @@ -505,14 +505,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); diff --git a/platform/windows.c b/platform/windows.c index ec094700..c73a7a38 100644 --- a/platform/windows.c +++ b/platform/windows.c @@ -1182,14 +1182,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);