From a04a82ca4a9ab7e55d6425bb29f67f929a3f3f45 Mon Sep 17 00:00:00 2001 From: havoc Date: Tue, 8 Mar 2005 17:56:22 +0000 Subject: [PATCH] made FS_Tell and FS_Seek work when writing files git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@5066 d7cf8633-e32d-0410-b094-e92efae38249 --- fs.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/fs.c b/fs.c index 9ad57055..b47d6117 100644 --- a/fs.c +++ b/fs.c @@ -1674,6 +1674,11 @@ int FS_Seek (qfile_t* file, long offset, int whence) qbyte* buffer; size_t buffersize; + // if this is an uncompressed real file we can just call the kernel seek + // (necessary when writing files) + if (file->offset == 0 && ! (file->flags & QFILE_FLAG_DEFLATED)) + return lseek (file->handle, offset, whence); + // Compute the file offset switch (whence) { @@ -1767,7 +1772,12 @@ Give the current position in a file */ long FS_Tell (qfile_t* file) { - return file->position - file->buff_len + file->buff_ind; + // if this is an uncompressed real file we can just call the kernel tell + // (necessary when writing files) + if (file->offset == 0 && ! (file->flags & QFILE_FLAG_DEFLATED)) + return lseek (file->handle, 0, SEEK_CUR); + else + return file->position - file->buff_len + file->buff_ind; } -- 2.39.2