libbb/bb_strtonum: always set end ptr, even on error return
[oweals/busybox.git] / archival / unzip.c
index 5d62c08cbf6399346cccdef9e0f10c73e3423dcf..3a11f78a553430bdaa59afcd12577452ebfa91f2 100644 (file)
  * Zip64 + other methods
  */
 
+//usage:#define unzip_trivial_usage
+//usage:       "[-opts[modifiers]] FILE[.zip] [LIST] [-x XLIST] [-d DIR]"
+//usage:#define unzip_full_usage "\n\n"
+//usage:       "Extract files from ZIP archives\n"
+//usage:     "\n       -l      List archive contents (with -q for short form)"
+//usage:     "\n       -n      Never overwrite files (default)"
+//usage:     "\n       -o      Overwrite"
+//usage:     "\n       -p      Send output to stdout"
+//usage:     "\n       -q      Quiet"
+//usage:     "\n       -x XLST Exclude these files"
+//usage:     "\n       -d DIR  Extract files into DIR"
+
 #include "libbb.h"
-#include "archive.h"
+#include "bb_archive.h"
 
 enum {
 #if BB_BIG_ENDIAN
@@ -223,7 +235,7 @@ static void unzip_create_leading_dirs(const char *fn)
        /* Create all leading directories */
        char *name = xstrdup(fn);
        if (bb_make_directory(dirname(name), 0777, FILEUTILS_RECUR)) {
-               bb_error_msg_and_die("exiting"); /* bb_make_directory is noisy */
+               xfunc_die(); /* bb_make_directory is noisy */
        }
        free(name);
 }
@@ -583,7 +595,7 @@ int unzip_main(int argc, char **argv)
                                        }
                                        unzip_create_leading_dirs(dst_fn);
                                        if (bb_make_directory(dst_fn, dir_mode, 0)) {
-                                               bb_error_msg_and_die("exiting");
+                                               xfunc_die();
                                        }
                                } else {
                                        if (!S_ISDIR(stat_buf.st_mode)) {
@@ -607,6 +619,7 @@ int unzip_main(int argc, char **argv)
                                                        i = 'y';
                                                } else {
                                                        printf("replace %s? [y]es, [n]o, [A]ll, [N]one, [r]ename: ", dst_fn);
+                                                       fflush_all();
                                                        if (!fgets(key_buf, sizeof(key_buf), stdin)) {
                                                                bb_perror_msg_and_die("can't read input");
                                                        }