Fixed __PHYSFS_platformTell() things in stable-1.0 branch. stable-1.0
authorRyan C. Gordon <icculus@icculus.org>
Mon, 01 Aug 2011 17:55:45 -0400
branchstable-1.0
changeset 1179 eea580b4e199
parent 1177 05a842260409
child 1184 dedd6ba3868f
Fixed __PHYSFS_platformTell() things in stable-1.0 branch.
physfs_internal.h
platform/pocketpc.c
platform/posix.c
platform/win32.c
--- a/physfs_internal.h	Mon Aug 01 17:37:06 2011 -0400
+++ b/physfs_internal.h	Mon Aug 01 17:55:45 2011 -0400
@@ -1431,8 +1431,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:55:45 2011 -0400
@@ -553,7 +553,7 @@
     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 @@
         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:55:45 2011 -0400
@@ -478,7 +478,7 @@
 {
     PHYSFS_sint64 pos = __PHYSFS_platformTell(opaque);
     PHYSFS_sint64 len = __PHYSFS_platformFileLength(opaque);
-    return(pos >= len);
+    return((pos < 0) || (len < 0) || (pos >= len));
 } /* __PHYSFS_platformEOF */
 
 
--- a/platform/win32.c	Mon Aug 01 17:37:06 2011 -0400
+++ b/platform/win32.c	Mon Aug 01 17:55:45 2011 -0400
@@ -897,7 +897,7 @@
     if ( (LowPos == PHYSFS_INVALID_SET_FILE_POINTER) &&
          (GetLastError() != NO_ERROR) )
     {
-        BAIL_MACRO(win32strerror(), 0);
+        BAIL_MACRO(win32strerror(), -1);
     } /* if */
     else
     {
@@ -944,7 +944,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);