Skip to content

Commit

Permalink
Seeking backwards in ZIP_seek() works now.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Jul 17, 2002
1 parent c7f3a2b commit f558dcf
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions archivers/zip.c
Expand Up @@ -351,6 +351,9 @@ static int ZIP_seek(FileHandle *handle, PHYSFS_uint64 offset)
if (zlib_err(inflateInit2(&str, -MAX_WBITS)) != Z_OK)
return(0);

if (!__PHYSFS_platformSeek(in, entry->offset))
return(0);

inflateEnd(&finfo->stream);
memcpy(&finfo->stream, &str, sizeof (z_stream));
finfo->uncompressed_position = finfo->compressed_position = 0;
Expand Down Expand Up @@ -1086,7 +1089,7 @@ static int ZIP_exists(DirHandle *h, const char *name)

/* if it's a symlink, then we ran into a possible symlink loop. */
is_sym = ( ((ZIPinfo *)(h->opaque))->entries[pos].symlink != NULL );
BAIL_IF_MACRO(is_sym, ERR_TOO_MANY_SYMLINKS, 0);
BAIL_IF_MACRO(is_sym, ERR_SYMLINK_LOOP, 0);

return(1);
} /* ZIP_exists */
Expand All @@ -1103,7 +1106,7 @@ static PHYSFS_sint64 ZIP_getLastModTime(DirHandle *h, const char *name)
entry = &zi->entries[pos];

/* if it's a symlink, then we ran into a possible symlink loop. */
BAIL_IF_MACRO(entry->symlink != NULL, ERR_TOO_MANY_SYMLINKS, 0);
BAIL_IF_MACRO(entry->symlink != NULL, ERR_SYMLINK_LOOP, 0);

return(entry->last_mod_time);
} /* ZIP_getLastModTime */
Expand All @@ -1119,7 +1122,7 @@ static int ZIP_isDirectory(DirHandle *h, const char *name)

/* if it's a symlink, then we ran into a possible symlink loop. */
is_sym = ( ((ZIPinfo *)(h->opaque))->entries[pos].symlink != NULL );
BAIL_IF_MACRO(is_sym, ERR_TOO_MANY_SYMLINKS, 0);
BAIL_IF_MACRO(is_sym, ERR_SYMLINK_LOOP, 0);

dlen = strlen(name);

Expand Down Expand Up @@ -1147,7 +1150,7 @@ static FileHandle *ZIP_openRead(DirHandle *h, const char *filename)
BAIL_IF_MACRO(pos == -1, ERR_NO_SUCH_FILE, NULL);

/* if it's a symlink, then we ran into a possible symlink loop. */
BAIL_IF_MACRO(zi->entries[pos].symlink != NULL, ERR_TOO_MANY_SYMLINKS, 0);
BAIL_IF_MACRO(zi->entries[pos].symlink != NULL, ERR_SYMLINK_LOOP, 0);

in = __PHYSFS_platformOpenRead(zi->archiveName);
BAIL_IF_MACRO(in == NULL, ERR_IO_ERROR, NULL);
Expand Down

0 comments on commit f558dcf

Please sign in to comment.