Skip to content

Commit fe9b0e0

Browse files
committed
FS: Remove last traces of iscompressed in vfs_zip.
Most of the uses had already been removed, but remained in the case of a seek. As cmodel now uses seeks during checksum, this uncovered the last use case. As iscompressed wasn't set, the vfsz->defer remained NULL, and thus reading of pk3 content after a seek failed. The origin of this file is FTE, ideally a newer version is imported but the rest of the FTE VFS guts has evolved since last import. fixes #885
1 parent fe56fee commit fe9b0e0

File tree

1 file changed

+28
-59
lines changed

1 file changed

+28
-59
lines changed

src/vfs_zip.c

+28-59
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ typedef struct {
138138

139139
//in case we're forced away.
140140
zipfile_t *parent;
141-
qbool iscompressed;
142141
int pos;
143142
int length; //try and optimise some things
144143
int index;
@@ -181,23 +180,9 @@ static int VFSZIP_ReadBytes (struct vfsfile_s *file, void *buffer, int bytestore
181180
if (vfsz->defer)
182181
return VFS_READ(vfsz->defer, buffer, bytestoread, err);
183182

184-
// if (vfsz->iscompressed)
185-
// {
186-
VFSZIP_MakeActive(vfsz);
187-
read = unzReadCurrentFile(vfsz->parent->handle, buffer, bytestoread);
188-
// }
189-
// else
190-
// {
191-
// VFS-FIXME This stuff seems to be only for optimisation,
192-
// hence we can probably just go with unzReadCurrentFile
193-
// if (vfsz->parent->currentfile != file)
194-
// {
195-
// unzCloseCurrentFile(vfsz->parent->handle);
196-
// VFS_SEEK(vfsz->parent->raw, vfsz->pos+vfsz->startpos, SEEK_SET);
197-
// vfsz->parent->currentfile = file;
198-
// }
199-
// read = VFS_READ(vfsz->parent->raw, buffer, bytestoread, err);
200-
// }
183+
VFSZIP_MakeActive(vfsz);
184+
read = unzReadCurrentFile(vfsz->parent->handle, buffer, bytestoread);
185+
201186
if (err)
202187
*err = ((read || bytestoread <= 0) ? VFSERR_NONE : VFSERR_EOF);
203188

@@ -222,35 +207,32 @@ static int VFSZIP_Seek (struct vfsfile_s *file, unsigned long pos, int whence)
222207
//This is *really* inefficient
223208
if (vfsz->parent->currentfile == file)
224209
{
225-
if (vfsz->iscompressed)
226-
{ //if they're going to seek on a file in a zip, let's just copy it out
227-
char buffer[8192];
228-
unsigned int chunk;
229-
unsigned int i;
230-
unsigned int length;
231-
232-
vfsz->defer = FS_OpenTemp();
233-
if (vfsz->defer)
210+
char buffer[8192];
211+
unsigned int chunk;
212+
unsigned int i;
213+
unsigned int length;
214+
215+
vfsz->defer = FS_OpenTemp();
216+
if (vfsz->defer)
217+
{
218+
unzCloseCurrentFile(vfsz->parent->handle);
219+
vfsz->parent->currentfile = NULL; //make it not us
220+
221+
length = vfsz->length;
222+
i = 0;
223+
vfsz->pos = 0;
224+
VFSZIP_MakeActive(vfsz);
225+
while (1)
234226
{
235-
unzCloseCurrentFile(vfsz->parent->handle);
236-
vfsz->parent->currentfile = NULL; //make it not us
237-
238-
length = vfsz->length;
239-
i = 0;
240-
vfsz->pos = 0;
241-
VFSZIP_MakeActive(vfsz);
242-
while (1)
243-
{
244-
chunk = length - i;
245-
if (chunk > sizeof(buffer))
246-
chunk = sizeof(buffer);
247-
if (chunk == 0)
248-
break;
249-
unzReadCurrentFile(vfsz->parent->handle, buffer, chunk);
250-
VFS_WRITE(vfsz->defer, buffer, chunk);
251-
252-
i += chunk;
253-
}
227+
chunk = length - i;
228+
if (chunk > sizeof(buffer))
229+
chunk = sizeof(buffer);
230+
if (chunk == 0)
231+
break;
232+
unzReadCurrentFile(vfsz->parent->handle, buffer, chunk);
233+
VFS_WRITE(vfsz->defer, buffer, chunk);
234+
235+
i += chunk;
254236
}
255237
}
256238

@@ -327,19 +309,6 @@ static vfsfile_t *FSZIP_OpenVFS(void *handle, flocation_t *loc, char *mode)
327309
if (loc->search)
328310
vfsz->funcs.copyprotected = loc->search->copyprotected;
329311

330-
// VFS-FIXME:
331-
// What is the point of is compressed etc
332-
333-
//unzLocateFileMy(vfsz->parent->handle, vfsz->index, vfsz->startpos);
334-
//rawofs = unzGetCurrentFileUncompressedPos(zip->handle);
335-
/*vfsz->iscompressed = 1; // rawofs<0;
336-
if (!vfsz->iscompressed)
337-
{
338-
vfsz->startpos = rawofs;
339-
VFS_SEEK(zip->raw, vfsz->startpos, SEEK_SET);
340-
vfsz->parent->currentfile = (vfsfile_t*)vfsz;
341-
}*/
342-
343312
zip->references++;
344313

345314
return (vfsfile_t*)vfsz;

0 commit comments

Comments
 (0)