X-Git-Url: https://git.brokenzipper.com/gitweb?a=blobdiff_plain;f=src%2Fbuffer.c;h=50b474936939f0e606c8c2dc504581611ef09a00;hb=1a1cfaafa64c6255b237cdd4fe679c1829d3f7e2;hp=783dd6ef6afd6e6eb9277e634c97049f27a8d810;hpb=c027e039249b82c86eb947cae09a28b50dde30de;p=chaz%2Ftar diff --git a/src/buffer.c b/src/buffer.c index 783dd6e..50b4749 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -436,16 +436,6 @@ _open_archive (enum access_mode wanted_access) { int backed_up_flag = 0; - if (index_file_name) - { - stdlis = freopen (index_file_name, "w", stdout); - if (! stdlis) - open_error (index_file_name); - close_stdout_set_file_name (index_file_name); - } - else - stdlis = to_stdout_option ? stderr : stdout; - if (record_size == 0) FATAL_ERROR ((0, 0, _("Invalid value for record_size"))); @@ -485,7 +475,8 @@ _open_archive (enum access_mode wanted_access) break; } - if (wanted_access == ACCESS_WRITE + if (!index_file_name + && wanted_access == ACCESS_WRITE && strcmp (archive_name_array[0], "-") == 0) stdlis = stderr; } @@ -513,14 +504,16 @@ _open_archive (enum access_mode wanted_access) case ACCESS_WRITE: archive = STDOUT_FILENO; - stdlis = stderr; + if (!index_file_name) + stdlis = stderr; break; case ACCESS_UPDATE: archive = STDIN_FILENO; - stdlis = stderr; write_archive_to_stdout = true; record_end = record_start; /* set up for 1st record = # 0 */ + if (!index_file_name) + stdlis = stderr; break; } } @@ -1036,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); @@ -1130,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 ();