gzstream SEEK_END support

git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@6089 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
Lee Salzman
2011-02-11 08:57:42 +00:00
parent ed6975c9d4
commit 8e7e4b87bf
+8 -2
View File
@@ -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;