static int unzzip_cat (int argc, char ** argv, int extract)
{
+ int done = 0;
int argn;
FILE* disk;
if (argc == 2)
{ /* print directory list */
- int warnings = 0;
ZZIP_ENTRY* entry = zzip_entry_findfirst(disk);
for (; entry ; entry = zzip_entry_findnext(entry))
{
char* name = zzip_entry_strdup_name (entry);
FILE* out = stdout;
if (! name) {
- warnings += 1;
+ done = EXIT_WARNINGS;
continue;
}
if (extract) out = create_fopen(name, "w", 1);
+ if (! out) {
+ done = EXIT_ERRORS;
+ continue;
+ }
unzzip_cat_file (disk, name, out);
if (extract) fclose(out);
free (name);
}
- if (warnings) {
- return EXIT_WARNINGS;
- }
- return 0;
+ return done;
}
if (argc == 3 && !extract)
{
FILE* out = stdout;
if (extract) out = create_fopen(name, "w", 1);
+ if (! out) {
+ done = EXIT_ERRORS;
+ continue;
+ }
unzzip_cat_file (disk, name, out);
if (extract) fclose(out);
break; /* match loop */
free (name);
}
}
- return 0;
+ return done;
}
int unzzip_print (int argc, char ** argv)
ZZIP_DISK_FILE* file = zzip_mem_disk_fopen (disk, name);
if (file)
{
- char buffer[1024]; int len;
+ char buffer[1025]; int len;
while ((len = zzip_mem_disk_fread (buffer, 1, 1024, file)))
{
fwrite (buffer, 1, len, out);
static int unzzip_cat (int argc, char ** argv, int extract)
{
+ int done;
int argn;
ZZIP_MEM_DISK* disk;
char* name = zzip_mem_entry_to_name (entry);
FILE* out = stdout;
if (extract) out = create_fopen(name, "w", 1);
+ if (! out) {
+ done = EXIT_ERRORS;
+ continue;
+ }
unzzip_mem_disk_cat_file (disk, name, out);
if (extract) fclose(out);
}
- return 0;
+ return done;
}
if (argc == 3 && !extract)
{
FILE* out = stdout;
if (extract) out = create_fopen(name, "w", 1);
+ if (! out) {
+ done = EXIT_ERRORS;
+ continue;
+ }
unzzip_mem_disk_cat_file (disk, name, out);
if (extract) fclose(out);
break; /* match loop */
}
}
}
- return 0;
+ return done;
}
int unzzip_print (int argc, char ** argv)
static int unzzip_cat (int argc, char ** argv, int extract)
{
+ int done = 0;
int argn;
ZZIP_DIR* disk;
char* name = entry->d_name;
FILE* out = stdout;
if (extract) out = create_fopen(name, "w", 1);
+ if (! out) {
+ done = EXIT_ERRORS;
+ continue;
+ }
unzzip_cat_file (disk, name, out);
if (extract) fclose(out);
}
mix_name[zip_name_len] = '/';
strcpy(mix_name + zip_name_len + 1, name);
if (extract) out = create_fopen(name, "w", 1);
+ if (! out) {
+ done = EXIT_ERRORS;
+ continue;
+ }
fprintf(stderr, "%s %s -> %s\n", zip_name, name, mix_name);
/* 'test1.zip' 'README' -> 'test1/README' */
unzzip_cat_file (disk, mix_name, out);
}
}
zzip_closedir(disk);
- return 0;
+ return done;
}
int unzzip_print (int argc, char ** argv)
static int unzzip_cat (int argc, char ** argv, int extract)
{
+ int done = 0;
int argn;
ZZIP_DIR* disk;
zzip_error_t error;
char* name = entry.d_name;
FILE* out = stdout;
if (extract) out = create_fopen(name, "w", 1);
- if (out) {
- unzzip_cat_file (disk, name, out);
- if (extract) fclose(out);
+ if (! out) {
+ done = EXIT_ERRORS;
+ continue;
}
+ unzzip_cat_file (disk, name, out);
+ if (extract) fclose(out);
}
}
else
{
FILE* out = stdout;
if (extract) out = create_fopen(name, "w", 1);
- if (out) {
- unzzip_cat_file (disk, name, out);
- if (extract) fclose(out);
+ if (! out) {
+ done = EXIT_ERRORS;
+ continue;
}
+ unzzip_cat_file (disk, name, out);
+ if (extract) fclose(out);
break; /* match loop */
}
}
}
}
zzip_dir_close(disk);
- return 0;
+ return done;
}
int unzzip_print (int argc, char ** argv)