X-Git-Url: https://git.brokenzipper.com/gitweb?a=blobdiff_plain;f=src%2Fbuffer.c;h=50b474936939f0e606c8c2dc504581611ef09a00;hb=603c1d60a63b8dc60382c562f5fb0ab94037e62c;hp=77ebe272f14b827a26f6506b587787917ee45b11;hpb=89f1667fdbb8c6c05f666690c93c485e9c1a12eb;p=chaz%2Ftar diff --git a/src/buffer.c b/src/buffer.c index 77ebe27..50b4749 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -474,6 +474,11 @@ _open_archive (enum access_mode wanted_access) abort (); /* Should not happen */ break; } + + if (!index_file_name + && wanted_access == ACCESS_WRITE + && strcmp (archive_name_array[0], "-") == 0) + stdlis = stderr; } else if (strcmp (archive_name_array[0], "-") == 0) { @@ -499,12 +504,16 @@ _open_archive (enum access_mode wanted_access) case ACCESS_WRITE: archive = STDOUT_FILENO; + if (!index_file_name) + stdlis = stderr; break; case ACCESS_UPDATE: archive = STDIN_FILENO; write_archive_to_stdout = true; record_end = record_start; /* set up for 1st record = # 0 */ + if (!index_file_name) + stdlis = stderr; break; } } @@ -1020,7 +1029,8 @@ new_volume (enum access_mode mode) assign_string (&volume_label, NULL); assign_string (&continued_file_name, NULL); continued_file_size = continued_file_offset = 0; - + current_block = record_start; + if (rmtclose (archive) != 0) close_warn (*archive_name_cursor); @@ -1114,22 +1124,24 @@ try_new_volume () size_t status; union block *header; struct tar_stat_info dummy; - + int access; + switch (subcommand_option) { case APPEND_SUBCOMMAND: case CAT_SUBCOMMAND: case UPDATE_SUBCOMMAND: - if (!new_volume (ACCESS_UPDATE)) - return true; + access = ACCESS_UPDATE; break; default: - if (!new_volume (ACCESS_READ)) - return true; + access = ACCESS_READ; break; } + if (!new_volume (access)) + return true; + while ((status = rmtread (archive, record_start->buffer, record_size)) == SAFE_READ_ERROR) archive_read_error ();