cmSystemTools: Re-order extract_tar logic

Simplify extraction message logic to be easier to follow and to write a
newline before any error messages that may be produced.  Also flip
handling of the archive_write_header return code to handle success in
the "then" case and failure in the "else" case.
This commit is contained in:
Brad King 2013-11-01 16:52:18 -04:00
parent 37b6c1dcb3
commit 0d8552c459
1 changed files with 21 additions and 20 deletions

View File

@ -1619,18 +1619,23 @@ bool extract_tar(const char* outFileName, bool verbose,
archive_error_string(a)); archive_error_string(a));
break; break;
} }
if (verbose && extract) if(verbose)
{ {
cmSystemTools::Stdout("x "); if(extract)
cmSystemTools::Stdout(archive_entry_pathname(entry)); {
} cmSystemTools::Stdout("x ");
if(verbose && !extract) cmSystemTools::Stdout(archive_entry_pathname(entry));
{ }
list_item_verbose(stdout, entry); else
{
list_item_verbose(stdout, entry);
}
cmSystemTools::Stdout("\n");
} }
else if(!extract) else if(!extract)
{ {
cmSystemTools::Stdout(archive_entry_pathname(entry)); cmSystemTools::Stdout(archive_entry_pathname(entry));
cmSystemTools::Stdout("\n");
} }
if(extract) if(extract)
{ {
@ -1644,15 +1649,7 @@ bool extract_tar(const char* outFileName, bool verbose,
} }
r = archive_write_header(ext, entry); r = archive_write_header(ext, entry);
if (r != ARCHIVE_OK) if (r == ARCHIVE_OK)
{
cmSystemTools::Error("Problem with archive_write_header(): ",
archive_error_string(ext));
cmSystemTools::Error("Current file: ",
archive_entry_pathname(entry));
break;
}
else
{ {
copy_data(a, ext); copy_data(a, ext);
r = archive_write_finish_entry(ext); r = archive_write_finish_entry(ext);
@ -1663,10 +1660,14 @@ bool extract_tar(const char* outFileName, bool verbose,
break; break;
} }
} }
} else
if (verbose || !extract) {
{ cmSystemTools::Error("Problem with archive_write_header(): ",
cmSystemTools::Stdout("\n"); archive_error_string(ext));
cmSystemTools::Error("Current file: ",
archive_entry_pathname(entry));
break;
}
} }
} }
archive_read_close(a); archive_read_close(a);