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.
This commit is contained in:
parent
df254ce03b
commit
0bc9eab243
|
@ -16,6 +16,7 @@ xz_SOURCES = \
|
|||
file_io.h \
|
||||
hardware.c \
|
||||
hardware.h \
|
||||
list.c \
|
||||
main.c \
|
||||
main.h \
|
||||
message.c \
|
||||
|
|
1072
src/xz/list.c
1072
src/xz/list.c
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,18 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
/// \file list.h
|
||||
/// \brief List information about .xz files
|
||||
//
|
||||
// Author: Lasse Collin
|
||||
//
|
||||
// This file has been put into the public domain.
|
||||
// You can do whatever you want with this file.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/// \brief List information about the given .xz file
|
||||
extern void list_file(const char *filename);
|
||||
|
||||
|
||||
/// \brief Show the totals after all files have been listed
|
||||
extern void list_totals(void);
|
|
@ -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();
|
||||
|
|
|
@ -48,3 +48,4 @@
|
|||
#include "signals.h"
|
||||
#include "suffix.h"
|
||||
#include "util.h"
|
||||
#include "list.h"
|
||||
|
|
Loading…
Reference in New Issue