Always write end record unless one has already been written.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@51008 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Michael Wetherell
2008-01-03 17:09:10 +00:00
parent e60f8377be
commit dd0af4bb63
4 changed files with 18 additions and 9 deletions

View File

@@ -1083,12 +1083,12 @@ void wxTarOutputStream::Init(wxTarFormat format)
m_extendedHdr = NULL;
m_extendedSize = 0;
m_lasterror = m_parent_o_stream->GetLastError();
m_endrecWritten = false;
}
wxTarOutputStream::~wxTarOutputStream()
{
if (m_tarsize)
Close();
Close();
delete m_hdr;
delete m_hdr2;
delete [] m_extendedHdr;
@@ -1207,9 +1207,9 @@ bool wxTarOutputStream::CloseEntry()
bool wxTarOutputStream::Close()
{
if (!CloseEntry())
if (!CloseEntry() || (m_tarsize == 0 && m_endrecWritten))
return false;
memset(m_hdr, 0, sizeof(*m_hdr));
int count = (RoundUpSize(m_tarsize + 2 * TAR_BLOCKSIZE, m_BlockingFactor)
- m_tarsize) / TAR_BLOCKSIZE;
@@ -1219,6 +1219,7 @@ bool wxTarOutputStream::Close()
m_tarsize = 0;
m_tarstart = wxInvalidOffset;
m_lasterror = m_parent_o_stream->GetLastError();
m_endrecWritten = true;
return IsOk();
}