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
{
char name [MAX_QPATH];
packfile_flags_t flags;
- size_t offset;
- size_t packsize; // size in the package
- size_t realsize; // real file size (uncompressed)
+ fs_offset_t offset;
+ fs_offset_t packsize; // size in the package
+ fs_offset_t realsize; // real file size (uncompressed)
} packfile_t;
typedef struct pack_s
{
const char* dllnames [] =
{
-#ifdef WIN32
+#if defined(WIN64)
+ "zlib64.dll",
+#elif defined(WIN32)
"zlib.dll",
#elif defined(MACOSX)
"libz.dylib",
if (strstr(com_argv[0], ".app/"))
{
char *split;
- char temp[4096];
+
split = strstr(com_argv[0], ".app/");
while (split > com_argv[0] && *split != '/')
split--;
FS_Purge (file);
// Write the buffer and update the position
- result = write (file->handle, data, datasize);
+ result = write (file->handle, data, (fs_offset_t)datasize);
file->position = lseek (file->handle, 0, SEEK_CUR);
if (file->real_length < file->position)
file->real_length = file->position;
// 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 = (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;
if (file->position == file->real_length)
return done;
- count = ztk->comp_length - ztk->in_position;
+ count = (fs_offset_t)(ztk->comp_length - ztk->in_position);
if (count > (fs_offset_t)sizeof (ztk->input))
count = (fs_offset_t)sizeof (ztk->input);
- lseek (file->handle, file->offset + ztk->in_position, SEEK_SET);
- if (read (file->handle, ztk->input, count) != (fs_offset_t)count)
+ lseek (file->handle, file->offset + (fs_offset_t)ztk->in_position, SEEK_SET);
+ if (read (file->handle, ztk->input, count) != count)
{
Con_Printf ("FS_Read: unexpected end of file");
break;
}
ztk->in_ind = ztk->in_len - ztk->zstream.avail_in;
- file->buff_len = sizeof (file->buff) - ztk->zstream.avail_out;
+ 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 = (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;
}
ztk->in_ind = ztk->in_len - ztk->zstream.avail_in;
// How much data did it inflate?
- count = buffersize - ztk->zstream.avail_out;
+ count = (fs_offset_t)(buffersize - ztk->zstream.avail_out);
file->position += count;
// Purge cached data
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;