From 8ae1b528a0940a02337dc6f0401e45b8fa5f2ef1 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Mon, 1 Aug 2011 17:55:45 -0400 Subject: [PATCH] Fixed __PHYSFS_platformTell() things in stable-1.0 branch. --- physfs_internal.h | 3 +-- platform/pocketpc.c | 4 ++-- platform/posix.c | 2 +- platform/win32.c | 4 ++-- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/physfs_internal.h b/physfs_internal.h index e161478d..5a15b80f 100644 --- a/physfs_internal.h +++ b/physfs_internal.h @@ -1431,8 +1431,7 @@ int __PHYSFS_platformSeek(void *opaque, PHYSFS_uint64 pos); * * Not all file types can "tell"; this is to be expected by the caller. * - * On error, call __PHYSFS_setError() and return zero. On success, return - * a non-zero value. + * On error, call __PHYSFS_setError() and return -1. On success, return >= 0. */ PHYSFS_sint64 __PHYSFS_platformTell(void *opaque); diff --git a/platform/pocketpc.c b/platform/pocketpc.c index 93314eb6..b8302fde 100644 --- a/platform/pocketpc.c +++ b/platform/pocketpc.c @@ -553,7 +553,7 @@ PHYSFS_sint64 __PHYSFS_platformTell(void *opaque) LowPos = SetFilePointer(FileHandle, 0, &HighPos, FILE_CURRENT); if ((LowPos == INVALID_SET_FILE_POINTER) && (GetLastError() != NO_ERROR)) { - BAIL_MACRO(win32strerror(), 0); + BAIL_MACRO(win32strerror(), -1); } /* if */ else { @@ -599,7 +599,7 @@ int __PHYSFS_platformEOF(void *opaque) return 1; /* we're definitely at EOF. */ /* Get the current position in the file */ - if ((FilePosition = __PHYSFS_platformTell(opaque)) != 0) + if ((FilePosition = __PHYSFS_platformTell(opaque)) != -1) { /* Non-zero if EOF is equal to the file length */ retval = (FilePosition == FileLength); diff --git a/platform/posix.c b/platform/posix.c index eab40a6e..4893b49b 100644 --- a/platform/posix.c +++ b/platform/posix.c @@ -478,7 +478,7 @@ int __PHYSFS_platformEOF(void *opaque) { PHYSFS_sint64 pos = __PHYSFS_platformTell(opaque); PHYSFS_sint64 len = __PHYSFS_platformFileLength(opaque); - return(pos >= len); + return((pos < 0) || (len < 0) || (pos >= len)); } /* __PHYSFS_platformEOF */ diff --git a/platform/win32.c b/platform/win32.c index c4b4a1f1..b0291df9 100644 --- a/platform/win32.c +++ b/platform/win32.c @@ -897,7 +897,7 @@ PHYSFS_sint64 __PHYSFS_platformTell(void *opaque) if ( (LowPos == PHYSFS_INVALID_SET_FILE_POINTER) && (GetLastError() != NO_ERROR) ) { - BAIL_MACRO(win32strerror(), 0); + BAIL_MACRO(win32strerror(), -1); } /* if */ else { @@ -944,7 +944,7 @@ int __PHYSFS_platformEOF(void *opaque) return 1; /* we're definitely at EOF. */ /* Get the current position in the file */ - if ((FilePosition = __PHYSFS_platformTell(opaque)) != 0) + if ((FilePosition = __PHYSFS_platformTell(opaque)) != -1 { /* Non-zero if EOF is equal to the file length */ retval = (FilePosition == FileLength);