Enough fixes to get the Build engine working with ZIP files instead of
GRPs. Currently does case-insensitive searching, which will change.
--- a/archivers/zip.c Mon Jul 23 09:23:17 2001 +0000
+++ b/archivers/zip.c Mon Jul 23 09:24:59 2001 +0000
@@ -96,7 +96,7 @@
{
/* this blows. */
unzFile fh = ((ZIPfileinfo *) (handle->opaque))->handle;
- char *buf;
+ char *buf = NULL;
int bufsize = 4096 * 2;
BAIL_IF_MACRO(unztell(fh) == offset, NULL, 1);
@@ -342,7 +342,7 @@
continue;
buf[dlen] = '\0';
- if (strcmp(d, buf) != 0) /* not same directory? */
+ if (__PHYSFS_platformStricmp(d, buf) != 0) /* not same directory? */
continue;
add_file = buf + dlen + 1;
@@ -356,7 +356,7 @@
*ptr = '\0';
for (j = retval; j != NULL; j = j->next)
{
- if (strcmp(j->str, ptr) == 0)
+ if (__PHYSFS_platformStricmp(j->str, ptr) == 0)
break;
} /* for */
@@ -521,14 +521,23 @@
f = unzOpen(name);
BAIL_IF_MACRO(f == NULL, ERR_IO_ERROR, NULL);
- if ( (unzLocateFile(f, filename, 1) != UNZ_OK) ||
- ( (finfo = (ZIPfileinfo *) malloc(sizeof (ZIPfileinfo))) == NULL ) ||
- (unzOpenCurrentFile(f) != UNZ_OK) )
+ if ( (unzLocateFile(f, filename, 2) != UNZ_OK) ||
+ (unzOpenCurrentFile(f) != UNZ_OK) ||
+ ( (finfo = (ZIPfileinfo *) malloc(sizeof (ZIPfileinfo))) == NULL ) )
{
unzClose(f);
BAIL_IF_MACRO(1, ERR_IO_ERROR, NULL);
} /* if */
+ if ( (!(retval = (FileHandle *) malloc(sizeof (FileHandle)))) ||
+ (!(retval->opaque = (ZIPfileinfo *) malloc(sizeof (ZIPfileinfo)))) )
+ {
+ if (retval)
+ free(retval);
+ unzClose(f);
+ BAIL_IF_MACRO(1, ERR_OUT_OF_MEMORY, NULL);
+ } /* if */
+
finfo->handle = f;
retval->opaque = (void *) finfo;
retval->funcs = &__PHYSFS_FileFunctions_ZIP;