int ungetc; // single stored character from ungetc, cleared to EOF when read
// Contents buffer
- size_t buff_ind, buff_len; // buffer current index and length
+ fs_offset_t buff_ind, buff_len; // buffer current index and length
qbyte buff [FILE_BUFF_SIZE];
// For zipped files
// If necessary, seek to the exact file position we're supposed to be
if (file->buff_ind != file->buff_len)
- lseek (file->handle, (fs_offset_t)(file->buff_ind - file->buff_len), SEEK_CUR);
+ lseek (file->handle, file->buff_ind - file->buff_len, SEEK_CUR);
// Purge cached data
FS_Purge (file);
// First, we copy as many bytes as we can from "buff"
if (file->buff_ind < file->buff_len)
{
- count = (fs_offset_t)(file->buff_len - file->buff_ind);
+ count = file->buff_len - file->buff_ind;
done += ((fs_offset_t)buffersize > count) ? count : (fs_offset_t)buffersize;
memcpy (buffer, &file->buff[file->buff_ind], done);
// If the file isn't compressed
if (! (file->flags & QFILE_FLAG_DEFLATED))
{
- int nb;
+ fs_offset_t nb;
// We must take care to not read after the end of the file
count = file->real_length - file->position;
file->position += nb;
// Copy the requested data in "buffer" (as much as we can)
- count = (fs_offset_t)((buffersize > file->buff_len) ? file->buff_len : buffersize);
+ count = (fs_offset_t)buffersize > file->buff_len ? file->buff_len : (fs_offset_t)buffersize;
memcpy (&((qbyte*)buffer)[done], file->buff, count);
file->buff_ind = count;
done += count;
}
ztk->in_ind = ztk->in_len - ztk->zstream.avail_in;
- file->buff_len = sizeof (file->buff) - ztk->zstream.avail_out;
- file->position += (fs_offset_t)file->buff_len;
+ file->buff_len = (fs_offset_t)sizeof (file->buff) - ztk->zstream.avail_out;
+ file->position += file->buff_len;
// Copy the requested data in "buffer" (as much as we can)
- count = (fs_offset_t)((buffersize > file->buff_len) ? file->buff_len : buffersize);
+ count = (fs_offset_t)buffersize > file->buff_len ? file->buff_len : (fs_offset_t)buffersize;
memcpy (&((qbyte*)buffer)[done], file->buff, count);
file->buff_ind = count;
}
switch (whence)
{
case SEEK_CUR:
- offset += (long)(file->position - file->buff_len + file->buff_ind);
+ offset += file->position - file->buff_len + file->buff_ind;
break;
case SEEK_SET:
break;
case SEEK_END:
- offset += (long)file->real_length;
+ offset += file->real_length;
break;
default:
return -1;
// If we have the data in our read buffer, we don't need to actually seek
- if (file->position - (fs_offset_t)file->buff_len <= offset
- && offset <= file->position)
+ if (file->position - file->buff_len <= offset && offset <= file->position)
{
file->buff_ind = offset + file->buff_len - file->position;
return 0;
*/
fs_offset_t FS_Tell (qfile_t* file)
{
- return file->position - (fs_offset_t)(file->buff_len + file->buff_ind);
+ return file->position - file->buff_len + file->buff_ind;
}