// Load the central directory in memory
central_dir = (unsigned char *)Mem_Alloc (tempmempool, eocd->cdir_size);
- lseek (pack->handle, eocd->cdir_offset, SEEK_SET);
+ if (lseek (pack->handle, eocd->cdir_offset, SEEK_SET) == -1)
+ {
+ Mem_Free (central_dir);
+ return -1;
+ }
if(read (pack->handle, central_dir, eocd->cdir_size) != (fs_offset_t) eocd->cdir_size)
{
Mem_Free (central_dir);
// If necessary, seek to the exact file position we're supposed to be
if (file->buff_ind != file->buff_len)
- lseek (file->handle, file->buff_ind - file->buff_len, SEEK_CUR);
+ {
+ if (lseek (file->handle, file->buff_ind - file->buff_len, SEEK_CUR) == -1)
+ {
+ Con_Printf("WARNING: could not seek in %s.\n");
+ }
+ }
// Purge cached data
FS_Purge (file);
{
if (count > (fs_offset_t)buffersize)
count = (fs_offset_t)buffersize;
- lseek (file->handle, file->offset + file->position, SEEK_SET);
+ if (lseek (file->handle, file->offset + file->position, SEEK_SET) == -1)
+ {
+ // Seek failed. When reading from a pipe, and
+ // the caller never called FS_Seek, this still
+ // works fine. So no reporting this error.
+ }
nb = read (file->handle, &((unsigned char*)buffer)[done], count);
if (nb > 0)
{
{
if (count > (fs_offset_t)sizeof (file->buff))
count = (fs_offset_t)sizeof (file->buff);
- lseek (file->handle, file->offset + file->position, SEEK_SET);
+ if (lseek (file->handle, file->offset + file->position, SEEK_SET) == -1)
+ {
+ // Seek failed. When reading from a pipe, and
+ // the caller never called FS_Seek, this still
+ // works fine. So no reporting this error.
+ }
nb = read (file->handle, file->buff, count);
if (nb > 0)
{
ztk->in_len = 0;
ztk->in_position = 0;
file->position = 0;
- lseek (file->handle, file->offset, SEEK_SET);
+ if (lseek (file->handle, file->offset, SEEK_SET) == -1)
+ Con_Printf("IMPOSSIBLE: couldn't seek in already opened pk3 file.\n");
// Reset the Zlib stream
ztk->zstream.next_in = ztk->input;