From a258da644fcf0667a93971adfc68e40badc756fa Mon Sep 17 00:00:00 2001 From: John Darrington Date: Tue, 28 Feb 2012 22:50:25 +0100 Subject: [PATCH 1/1] zip-test.c: More thorough error messages --- tests/libpspp/zip-test.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/tests/libpspp/zip-test.c b/tests/libpspp/zip-test.c index 7a2fcb10c4..ab55c11070 100644 --- a/tests/libpspp/zip-test.c +++ b/tests/libpspp/zip-test.c @@ -29,6 +29,7 @@ #include #include +#include #include "xalloc.h" /* Exit with a failure code. @@ -67,11 +68,29 @@ main (int argc, char **argv) int i; struct string str; struct zip_reader *zr = zip_reader_create (argv[2], &str); + if ( NULL == zr) + { + fprintf (stderr, "Could not create zip reader: %s\n", ds_cstr (&str)); + check_die (); + } for (i = 3; i < argc; ++i) { int x = 0; - struct zip_member *zm = zip_member_open (zr, argv[i]); + struct zip_member *zm ; FILE *fp = fopen (argv[i], "w"); + if ( NULL == fp) + { + int e = errno; + fprintf (stderr, "Could not create file %s: %s\n", argv[i], strerror(e)); + check_die (); + } + zm = zip_member_open (zr, argv[i]); + if ( NULL == zm) + { + fprintf (stderr, "Could not open zip member %s from archive: %s\n", + argv[i], ds_cstr (&str)); + check_die (); + } while ((x = zip_member_read (zm, buf, BUFSIZE)) > 0) { @@ -80,7 +99,7 @@ main (int argc, char **argv) fclose (fp); if ( x < 0) { - fprintf (stderr, "Unzip failed: %s", ds_cstr (&str)); + fprintf (stderr, "Unzip failed: %s\n", ds_cstr (&str)); check_die (); } -- 2.30.2