Fixed some __PHYSFS_platformTell() things in stable-2.0 branch. stable-2.0
authorRyan C. Gordon <icculus@icculus.org>
Mon, 01 Aug 2011 17:52:51 -0400
branchstable-2.0
changeset 1178 dec7e09cb3d9
parent 1175 e55bbdb69dfd
child 1183 9d2ec90ca841
Fixed some __PHYSFS_platformTell() things in stable-2.0 branch.
physfs_internal.h
platform/pocketpc.c
platform/posix.c
platform/windows.c
--- a/physfs_internal.h	Mon Aug 01 17:37:06 2011 -0400
+++ b/physfs_internal.h	Mon Aug 01 17:52:51 2011 -0400
@@ -1225,8 +1225,7 @@
  *
  * 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);
 
--- a/platform/pocketpc.c	Mon Aug 01 17:37:06 2011 -0400
+++ b/platform/pocketpc.c	Mon Aug 01 17:52:51 2011 -0400
@@ -467,7 +467,7 @@
     LowPos = SetFilePointer(Handle, 0, &HighPos, FILE_CURRENT);
     if ((LowPos == INVALID_SET_FILE_POINTER) && (GetLastError() != NO_ERROR))
     {
-        BAIL_MACRO(win32strerror(), 0);
+        BAIL_MACRO(win32strerror(), -1);
     } /* if */
     else
     {
@@ -513,7 +513,7 @@
         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);
--- a/platform/posix.c	Mon Aug 01 17:37:06 2011 -0400
+++ b/platform/posix.c	Mon Aug 01 17:52:51 2011 -0400
@@ -383,7 +383,7 @@
 {
     PHYSFS_sint64 pos = __PHYSFS_platformTell(opaque);
     PHYSFS_sint64 len = __PHYSFS_platformFileLength(opaque);
-    return(pos >= len);
+    return((tell < 0) || (len < 0) || (pos >= len));
 } /* __PHYSFS_platformEOF */
 
 
--- a/platform/windows.c	Mon Aug 01 17:37:06 2011 -0400
+++ b/platform/windows.c	Mon Aug 01 17:52:51 2011 -0400
@@ -1143,7 +1143,7 @@
     if ( (LowPos == PHYSFS_INVALID_SET_FILE_POINTER) &&
          (GetLastError() != NO_ERROR) )
     {
-        BAIL_MACRO(winApiStrError(), 0);
+        BAIL_MACRO(winApiStrError(), -1);
     } /* if */
     else
     {
@@ -1190,7 +1190,7 @@
         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);