Skip to content

Commit

Permalink
Cleaned up some stuff, reduced some unnecessary 64-bit ints to 32.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Aug 28, 2002
1 parent 0b75cdb commit 0eb5f71
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions archivers/grp.c
Expand Up @@ -44,8 +44,8 @@
typedef struct
{
char name[13];
PHYSFS_uint64 startPos;
PHYSFS_uint64 size;
PHYSFS_uint32 startPos;
PHYSFS_uint32 size;
} GRPentry;

typedef struct
Expand All @@ -60,7 +60,7 @@ typedef struct
{
void *handle;
GRPentry *entry;
PHYSFS_sint64 curPos;
PHYSFS_uint32 curPos;
} GRPfileinfo;


Expand Down Expand Up @@ -145,16 +145,16 @@ static PHYSFS_sint64 GRP_read(FileHandle *handle, void *buffer,
{
GRPfileinfo *finfo = (GRPfileinfo *) (handle->opaque);
GRPentry *entry = finfo->entry;
PHYSFS_uint64 bytesLeft = entry->size - finfo->curPos;
PHYSFS_uint64 objsLeft = (bytesLeft / objSize);
PHYSFS_uint32 bytesLeft = entry->size - finfo->curPos;
PHYSFS_uint32 objsLeft = (bytesLeft / objSize);
PHYSFS_sint64 rc;

if (objsLeft < objCount)
objCount = (PHYSFS_uint32) objsLeft;
objCount = objsLeft;

rc = __PHYSFS_platformRead(finfo->handle, buffer, objSize, objCount);
if (rc > 0)
finfo->curPos += (rc * objSize);
finfo->curPos += (PHYSFS_uint32) (rc * objSize);

return(rc);
} /* GRP_read */
Expand All @@ -171,7 +171,7 @@ static int GRP_eof(FileHandle *handle)
{
GRPfileinfo *finfo = (GRPfileinfo *) (handle->opaque);
GRPentry *entry = finfo->entry;
return(finfo->curPos >= (PHYSFS_sint64) entry->size);
return(finfo->curPos >= entry->size);
} /* GRP_eof */


Expand All @@ -185,22 +185,22 @@ static int GRP_seek(FileHandle *handle, PHYSFS_uint64 offset)
{
GRPfileinfo *finfo = (GRPfileinfo *) (handle->opaque);
GRPentry *entry = finfo->entry;
PHYSFS_uint64 newPos = (entry->startPos + offset);
int rc;

BAIL_IF_MACRO(offset < 0, ERR_INVALID_ARGUMENT, 0);
BAIL_IF_MACRO(newPos > entry->startPos + entry->size, ERR_PAST_EOF, 0);
rc = __PHYSFS_platformSeek(finfo->handle, newPos);
BAIL_IF_MACRO(offset >= entry->size, ERR_PAST_EOF, 0);
rc = __PHYSFS_platformSeek(finfo->handle, entry->startPos + offset);
if (rc)
finfo->curPos = offset;
finfo->curPos = (PHYSFS_uint32) offset;

return(rc);
} /* GRP_seek */


static PHYSFS_sint64 GRP_fileLength(FileHandle *handle)
{
return(((GRPfileinfo *) handle->opaque)->entry->size);
GRPfileinfo *finfo = ((GRPfileinfo *) handle->opaque);
return((PHYSFS_sint64) finfo->entry->size);
} /* GRP_fileLength */


Expand Down

0 comments on commit 0eb5f71

Please sign in to comment.