cacao_entry_s *ent;
unz_s *s=(unz_s*)file;
char *c;
- int i;
unz_file_info tmp;
char filename[200];
- if (unzGoToFirstFile(file) != UNZ_OK) {
- s->cacao_dir_list = NULL;
+ s->cacao_dir_list = NULL;
+
+ if (unzGoToFirstFile(file) != UNZ_OK)
return;
- }
- i = 0;
- ent = s->cacao_dir_list = NEW(cacao_entry_s);
- ent->next = NULL;
- ent->pos = s->pos_in_central_dir;
+ do {
+ if (unzGetCurrentFileInfo(file, &tmp, filename, 200, 0, 0, 0, 0) != UNZ_OK)
+ panic("Error in ZIP archive");
- if (unzGetCurrentFileInfo(file, &tmp, filename, 200, 0, 0, 0, 0) != UNZ_OK) {
- panic("Error in ZIP archive");
- }
+ if ((c = strstr(filename, ".class"))) {
+ *c = '\0';
- c = strstr(filename, ".class");
- if (c)
- *c = '\0';
+ if (!s->cacao_dir_list) {
+ ent = s->cacao_dir_list = NEW(cacao_entry_s);
- ent->name = utf_new_char(filename);
+ } else {
+ ent->next = NEW(cacao_entry_s);
+ ent = ent->next;
+ }
- while (unzGoToNextFile(file) == UNZ_OK) {
- i++;
- ent->next = NEW(cacao_entry_s);
- ent = ent->next;
- ent->next = NULL;
- ent->pos = s->pos_in_central_dir;
+ ent->next = NULL;
- if (unzGetCurrentFileInfo(file, &tmp, filename, 200, 0, 0, 0, 0) != UNZ_OK) {
- panic("Error in ZIP archive");
+ ent->name = utf_new_char(filename);
+ ent->pos = s->pos_in_central_dir;
}
-
- c = strstr(filename, ".class");
- if (c)
- *c = '\0';
-
- ent->name = utf_new_char(filename);
- }
- /*printf("Archive contains %d files\n",i);*/
+ } while (unzGoToNextFile(file) == UNZ_OK);
}