Skip to content

Commit

Permalink
Fixed some __PHYSFS_platformTell() things in stable-2.0 branch.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Aug 1, 2011
1 parent a7d5c1d commit f0cb6de
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
3 changes: 1 addition & 2 deletions physfs_internal.h
Expand Up @@ -1225,8 +1225,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);

Expand Down
4 changes: 2 additions & 2 deletions platform/pocketpc.c
Expand Up @@ -467,7 +467,7 @@ PHYSFS_sint64 __PHYSFS_platformTell(void *opaque)
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
{
Expand Down Expand Up @@ -513,7 +513,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);
Expand Down
2 changes: 1 addition & 1 deletion platform/posix.c
Expand Up @@ -383,7 +383,7 @@ int __PHYSFS_platformEOF(void *opaque)
{
PHYSFS_sint64 pos = __PHYSFS_platformTell(opaque);
PHYSFS_sint64 len = __PHYSFS_platformFileLength(opaque);
return(pos >= len);
return((tell < 0) || (len < 0) || (pos >= len));
} /* __PHYSFS_platformEOF */


Expand Down
4 changes: 2 additions & 2 deletions platform/windows.c
Expand Up @@ -1143,7 +1143,7 @@ PHYSFS_sint64 __PHYSFS_platformTell(void *opaque)
if ( (LowPos == PHYSFS_INVALID_SET_FILE_POINTER) &&
(GetLastError() != NO_ERROR) )
{
BAIL_MACRO(winApiStrError(), 0);
BAIL_MACRO(winApiStrError(), -1);
} /* if */
else
{
Expand Down Expand Up @@ -1190,7 +1190,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);
Expand Down

0 comments on commit f0cb6de

Please sign in to comment.