}
bool wxTarHeaderBlock::Read(wxInputStream& in)
-{
+{
bool ok = true;
for (int id = 0; id < TAR_NUMFIELDS && ok; id++)
bool wxTarHeaderBlock::SetOctal(int id, wxTarNumber n)
{
// set an octal field, return true if the number fits
- char *field = Get(id);
+ char *field = Get(id);
char *p = field + Len(id);
*--p = 0;
while (p > field) {
for (;;) {
fits = i < maxprefix && len - i <= maxname;
-
+
if (!fits) {
const char *p = strchr(mbName + i, '/');
if (p)
return fits && !badconv;
}
-
+
/////////////////////////////////////////////////////////////////////////////
// Some helpers
return m_Mode;
else
return m_Mode | 0111;
-
+
}
void wxTarEntry::SetMode(int mode)
// read the record size (byte count in ascii decimal)
recSize = 0;
- while (isdigit(*p))
+ while (isdigit((unsigned char) *p))
recSize = recSize * 10 + *p++ - '0';
// validity checks
if (value.empty())
recs->erase(key);
else
- (*recs)[key] = value;
+ (*recs)[key] = value;
}
if (!ok || recPos < len || size != lastread) {
size_t lastread = m_parent_i_stream->Read(buffer, size).LastRead();
m_pos += lastread;
-
+
if (m_pos >= m_size) {
m_lasterror = wxSTREAM_EOF;
} else if (!m_parent_i_stream->IsOk()) {
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;
bool wxTarOutputStream::Close()
{
- if (!CloseEntry())
+ if (!CloseEntry() || (m_tarsize == 0 && m_endrecWritten))
return false;
memset(m_hdr, 0, sizeof(*m_hdr));
m_tarsize = 0;
m_tarstart = wxInvalidOffset;
m_lasterror = m_parent_o_stream->GetLastError();
+ m_endrecWritten = true;
return IsOk();
}
*m_hdr->Get(TAR_TYPEFLAG) = char(entry.GetTypeFlag());
strcpy(m_hdr->Get(TAR_MAGIC), USTAR_MAGIC);
- strcpy(m_hdr->Get(TAR_VERSION), USTAR_VERSION);
+ strcpy(m_hdr->Get(TAR_VERSION), USTAR_VERSION);
SetHeaderString(TAR_LINKNAME, entry.GetLinkName());
SetHeaderString(TAR_UNAME, entry.GetUserName());
if (~entry.GetDevMajor())
SetHeaderNumber(TAR_DEVMAJOR, entry.GetDevMajor());
if (~entry.GetDevMinor())
- SetHeaderNumber(TAR_DEVMINOR, entry.GetDevMinor());
+ SetHeaderNumber(TAR_DEVMINOR, entry.GetDevMinor());
m_chksum = m_hdr->Sum();
m_hdr->SetOctal(TAR_CHKSUM, m_chksum);
strcpy(m_hdr2->Get(TAR_MTIME), m_hdr->Get(TAR_MTIME));
*m_hdr2->Get(TAR_TYPEFLAG) = 'x';
strcpy(m_hdr2->Get(TAR_MAGIC), USTAR_MAGIC);
- strcpy(m_hdr2->Get(TAR_VERSION), USTAR_VERSION);
+ strcpy(m_hdr2->Get(TAR_VERSION), USTAR_VERSION);
strcpy(m_hdr2->Get(TAR_UNAME), m_hdr->Get(TAR_UNAME));
strcpy(m_hdr2->Get(TAR_GNAME), m_hdr->Get(TAR_GNAME));
m_badfit.c_str(), entry.GetName().c_str());
m_badfit.clear();
}
-
+
m_hdr->Write(*m_parent_o_stream);
m_tarsize += TAR_BLOCKSIZE;
m_lasterror = m_parent_o_stream->GetLastError();
wxString d = path.BeforeLast(_T('/'));
wxString f = path.AfterLast(_T('/'));
wxString ret;
-
+
if (d.empty())
d = _T(".");