Another attempt at type size correctness.

This commit is contained in:
Ryan C. Gordon 2003-03-12 06:19:37 +00:00
parent 01505d8d58
commit 6f1d693fe8
3 changed files with 12 additions and 9 deletions

View File

@ -423,6 +423,7 @@ static PHYSFS_sint64 zip_find_end_of_central_dir(void *in, PHYSFS_sint64 *len)
filelen = __PHYSFS_platformFileLength(in); filelen = __PHYSFS_platformFileLength(in);
BAIL_IF_MACRO(filelen == -1, NULL, 0); BAIL_IF_MACRO(filelen == -1, NULL, 0);
BAIL_IF_MACRO(filelen > 0xFFFFFFFF, "ZIP bigger than 2 gigs?!", 0);
/* /*
* Jump to the end of the file and start reading backwards. * Jump to the end of the file and start reading backwards.
@ -444,7 +445,7 @@ static PHYSFS_sint64 zip_find_end_of_central_dir(void *in, PHYSFS_sint64 *len)
else else
{ {
filepos = 0; filepos = 0;
maxread = filelen; maxread = (PHYSFS_uint32) filelen;
} /* else */ } /* else */
while ((totalread < filelen) && (totalread < 65557)) while ((totalread < filelen) && (totalread < 65557))
@ -1062,7 +1063,7 @@ static int zip_parse_end_of_central_dir(void *in, DirHandle *dirh,
* sizeof central dir)...the difference in bytes is how much arbitrary * sizeof central dir)...the difference in bytes is how much arbitrary
* data is at the start of the physical file. * data is at the start of the physical file.
*/ */
*data_start = pos - (*central_dir_ofs + ui32); *data_start = (PHYSFS_uint32) (pos - (*central_dir_ofs + ui32));
/* Now that we know the difference, fix up the central dir offset... */ /* Now that we know the difference, fix up the central dir offset... */
*central_dir_ofs += *data_start; *central_dir_ofs += *data_start;

View File

@ -1710,9 +1710,9 @@ static PHYSFS_sint64 doBufferedRead(PHYSFS_file *handle, void *buffer,
while (objCount > 0) while (objCount > 0)
{ {
PHYSFS_uint64 buffered = h->buffill - h->bufpos; PHYSFS_uint32 buffered = h->buffill - h->bufpos;
PHYSFS_uint64 mustread = (objSize * objCount) - remainder; PHYSFS_uint64 mustread = (objSize * objCount) - remainder;
PHYSFS_uint64 copied; PHYSFS_uint32 copied;
if (buffered == 0) /* need to refill buffer? */ if (buffered == 0) /* need to refill buffer? */
{ {
@ -1723,12 +1723,12 @@ static PHYSFS_sint64 doBufferedRead(PHYSFS_file *handle, void *buffer,
return(((rc == -1) && (retval == 0)) ? -1 : retval); return(((rc == -1) && (retval == 0)) ? -1 : retval);
} /* if */ } /* if */
buffered = h->buffill = rc; buffered = h->buffill = (PHYSFS_uint32) rc;
h->bufpos = 0; h->bufpos = 0;
} /* if */ } /* if */
if (buffered > mustread) if (buffered > mustread)
buffered = mustread; buffered = (PHYSFS_uint32) mustread;
memcpy(buffer, h->buffer + h->bufpos, (size_t) buffered); memcpy(buffer, h->buffer + h->bufpos, (size_t) buffered);
buffer = ((PHYSFS_uint8 *) buffer) + buffered; buffer = ((PHYSFS_uint8 *) buffer) + buffered;
@ -1828,10 +1828,12 @@ PHYSFS_sint64 PHYSFS_fileLength(PHYSFS_file *handle)
} /* PHYSFS_filelength */ } /* PHYSFS_filelength */
int PHYSFS_setBuffer(PHYSFS_file *handle, PHYSFS_uint64 bufsize) int PHYSFS_setBuffer(PHYSFS_file *handle, PHYSFS_uint64 _bufsize)
{ {
FileHandle *h = (FileHandle *) handle->opaque; FileHandle *h = (FileHandle *) handle->opaque;
PHYSFS_uint32 bufsize = (PHYSFS_uint32) _bufsize;
BAIL_IF_MACRO(_bufsize > 0xFFFFFFFF, "buffer must fit in 32-bits", 0);
BAIL_IF_MACRO(!PHYSFS_flush(handle), NULL, 0); BAIL_IF_MACRO(!PHYSFS_flush(handle), NULL, 0);
/* /*

View File

@ -837,12 +837,12 @@ typedef struct __PHYSFS_FILEHANDLE__
/* /*
* This is the buffer fill size. Don't touch. * This is the buffer fill size. Don't touch.
*/ */
PHYSFS_uint64 buffill; PHYSFS_uint32 buffill;
/* /*
* This is the buffer position. Don't touch. * This is the buffer position. Don't touch.
*/ */
PHYSFS_uint64 bufpos; PHYSFS_uint32 bufpos;
/* /*
* This should be the DirHandle that created this FileHandle. * This should be the DirHandle that created this FileHandle.