(check_compressed_archive): Check remote archves as well

This commit is contained in:
Sergey Poznyakoff
2004-12-21 14:41:35 +00:00
parent f152367c57
commit ab3b31cfef

View File

@@ -177,8 +177,7 @@ static struct zip_magic magic[] = {
#define compress_option(t) magic[t].option #define compress_option(t) magic[t].option
#define compress_program(t) magic[t].program #define compress_program(t) magic[t].program
/* Check if the file FD is a compressed archive. FD is guaranteed to /* Check if the file ARCHIVE is a compressed archive. */
represent a local file */
enum compress_type enum compress_type
check_compressed_archive () check_compressed_archive ()
{ {
@@ -200,7 +199,7 @@ check_compressed_archive ()
read_full_records = sfr; read_full_records = sfr;
reading_from_pipe = srp; reading_from_pipe = srp;
if (tar_checksum (record_start) == HEADER_SUCCESS) if (tar_checksum (record_start, true) == HEADER_SUCCESS)
/* Probably a valid header */ /* Probably a valid header */
return ct_none; return ct_none;
@@ -222,20 +221,19 @@ open_compressed_archive ()
{ {
enum compress_type type; enum compress_type type;
int fd = rmtopen (archive_name_array[0], O_RDONLY | O_BINARY, archive = rmtopen (archive_name_array[0], O_RDONLY | O_BINARY,
MODE_RW, rsh_command_option); MODE_RW, rsh_command_option);
if (fd == -1 || _isrmt (fd)) if (archive == -1)
return fd; return archive;
archive = fd;
type = check_compressed_archive (); type = check_compressed_archive ();
if (type == ct_none) if (type == ct_none)
return fd; return archive;
/* FD is not needed any more */ /* FD is not needed any more */
rmtclose (fd); rmtclose (archive);
/* Open compressed archive */ /* Open compressed archive */
use_compress_program_option = compress_program (type); use_compress_program_option = compress_program (type);
child_pid = sys_child_open_for_uncompress (); child_pid = sys_child_open_for_uncompress ();