aboutsummaryrefslogtreecommitdiff
path: root/src/xz/list.c
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2010-01-31 12:01:54 +0200
committerLasse Collin <lasse.collin@tukaani.org>2010-01-31 12:01:54 +0200
commit231c3c7098f1099a56abb8afece76fc9b8699f05 (patch)
tree5887a319a46895b20f87075ba4f3b467a84bd85b /src/xz/list.c
parentAdd list.h to src/xz/Makefile.am. (diff)
downloadxz-231c3c7098f1099a56abb8afece76fc9b8699f05.tar.xz
Delay opening the destionation file and other fixes.
The opening of the destination file is now delayed a little. The coder is initialized, and if decompressing, the memory usage of the first Block compared against the memory usage limit before the destination file is opened. This means that if --force was used, the old "target" file won't be deleted so easily when something goes wrong very early. Thanks to Mark K for the bug report. The above fix required some changes to progress message handling. Now there is a separate function for setting and printing the filename. It is used also in list.c. list_file() now handles stdin correctly (gives an error). A useless check for user_abort was removed from file_io.c.
Diffstat (limited to 'src/xz/list.c')
-rw-r--r--src/xz/list.c28
1 files changed, 9 insertions, 19 deletions
diff --git a/src/xz/list.c b/src/xz/list.c
index bb793e02..1e487b55 100644
--- a/src/xz/list.c
+++ b/src/xz/list.c
@@ -444,15 +444,7 @@ print_adv_helper(uint64_t stream_count, uint64_t block_count,
static void
print_info_adv(const lzma_index *idx, file_pair *pair)
{
- // Print an empty line between files.
- static bool first_filename_printed = false;
- if (!first_filename_printed)
- first_filename_printed = true;
- else
- putchar('\n');
-
- // Print the filename and overall information.
- printf("%s (%" PRIu64 "):\n", pair->src_name, totals.files);
+ // Print the overall information.
print_adv_helper(lzma_index_stream_count(idx),
lzma_index_block_count(idx),
lzma_index_file_size(idx),
@@ -708,21 +700,19 @@ list_file(const char *filename)
message_fatal(_("--list works only on .xz files "
"(--format=xz or --format=auto)"));
- if (strcmp(filename, "-") == 0) {
+ message_filename(filename);
+
+ if (filename == stdin_filename) {
message_error(_("--list does not support reading from "
"standard input"));
return;
}
- if (is_empty_filename(filename))
- return;
-
- // Set opt_stdout so that io_open() won't create a new file.
- // Disable also sparse mode so that it doesn't remove O_APPEND
- // from stdout.
- opt_stdout = true;
- io_no_sparse();
- file_pair *pair = io_open(filename);
+ // Unset opt_stdout so that io_open_src() won't accept special files.
+ // Set opt_force so that io_open_src() will follow symlinks.
+ opt_stdout = false;
+ opt_force = true;
+ file_pair *pair = io_open_src(filename);
if (pair == NULL)
return;