]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
made FS_Tell and FS_Seek work when writing files
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 8 Mar 2005 17:56:22 +0000 (17:56 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 8 Mar 2005 17:56:22 +0000 (17:56 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@5066 d7cf8633-e32d-0410-b094-e92efae38249

fs.c

diff --git a/fs.c b/fs.c
index 9ad570557915918b2c082aaf285735c4e92c26e5..b47d611700e848c96f472b7941f87015205143dc 100644 (file)
--- 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;
 }