diff options
author | Lasse Collin <lasse.collin@tukaani.org> | 2010-01-24 23:50:54 +0200 |
---|---|---|
committer | Lasse Collin <lasse.collin@tukaani.org> | 2010-01-24 23:50:54 +0200 |
commit | 0bc9eab243dee3be764b3530433a7fcdc3f7c6a1 (patch) | |
tree | 694fda24e060ad34250224ab6088abc0c1e3bc95 /src/xz/main.c | |
parent | Add io_pread(). (diff) | |
download | xz-0bc9eab243dee3be764b3530433a7fcdc3f7c6a1.tar.xz |
Add initial version of xz --list.
This is a bit rough but should be useful for basic things.
Ideas (with detailed examples) about the output format are
welcome.
The output of --robot --list is not necessarily stable yet,
although I don't currently have any plans about changing it.
The man page hasn't been updated yet.
Diffstat (limited to 'src/xz/main.c')
-rw-r--r-- | src/xz/main.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/xz/main.c b/src/xz/main.c index 7445e98a..a2681f23 100644 --- a/src/xz/main.c +++ b/src/xz/main.c @@ -153,10 +153,7 @@ main(int argc, char **argv) args_info args; args_parse(&args, argc, argv); - if (opt_mode == MODE_LIST) - message_fatal("--list is not implemented yet."); - - if (opt_robot) + if (opt_mode != MODE_LIST && opt_robot) message_fatal(_("Compression and decompression with --robot " "are not supported yet.")); @@ -184,6 +181,11 @@ main(int argc, char **argv) // line arguments. signals_init(); + // coder_run() handles compression, decopmression, and testing. + // list_file() is for --list. + void (*run)(const char *filename) = opt_mode == MODE_LIST + ? &list_file : &coder_run; + // Process the files given on the command line. Note that if no names // were given, parse_args() gave us a fake "-" filename. for (size_t i = 0; i < args.arg_count && !user_abort; ++i) { @@ -218,7 +220,7 @@ main(int argc, char **argv) } // Do the actual compression or uncompression. - coder_run(args.arg_names[i]); + run(args.arg_names[i]); } // If --files or --files0 was used, process the filenames from the @@ -234,13 +236,18 @@ main(int argc, char **argv) // read_name() doesn't return empty names. assert(name[0] != '\0'); - coder_run(name); + run(name); } if (args.files_name != stdin_filename) (void)fclose(args.files_file); } + // All files have now been handled. If in --list mode, display + // the totals before exiting. + if (opt_mode == MODE_LIST) + list_totals(); + // If we have got a signal, raise it to kill the program instead // of calling tuklib_exit(). signals_exit(); |