From 8e7e4b87bfa0521d2969c8d933e1d8e1c64cc9a6 Mon Sep 17 00:00:00 2001 From: Lee Salzman Date: Fri, 11 Feb 2011 08:57:42 +0000 Subject: [PATCH] gzstream SEEK_END support git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@6089 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/stream.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/source/src/stream.cpp b/source/src/stream.cpp index 3974c73d..9c7f15e0 100644 --- a/source/src/stream.cpp +++ b/source/src/stream.cpp @@ -622,9 +622,15 @@ struct gzstream : stream bool seek(long offset, int whence) { - if(writing || !reading || whence == SEEK_END) return false; + if(writing || !reading) return false; - if(whence == SEEK_CUR) offset += zfile.total_out; + if(whence == SEEK_END) + { + uchar skip[512]; + while(read(skip, sizeof(skip)) == sizeof(skip)); + return !offset; + } + else if(whence == SEEK_CUR) offset += zfile.total_out; if(offset >= (int)zfile.total_out) offset -= zfile.total_out; else if(offset < 0 || !file->seek(headersize, SEEK_SET)) return false;