return ok;
}
-bool wxTarHeaderBlock::WriteField(wxOutputStream& out, int id)
+inline bool wxTarHeaderBlock::WriteField(wxOutputStream& out, int id)
{
return out.Write(Get(id), Len(id)).LastWrite() == Len(id);
}
size_t len = name.length();
wxCharBuffer approx(len);
for (size_t i = 0; i < len; i++)
- approx.data()[i] = name[i] & ~0x7F ? '_' : name[i];
+ {
+ wxChar c = name[i];
+ approx.data()[i] = c & ~0x7F ? '_' : c;
+ }
nameBuf = approx;
}
{
wxString value;
- if ((value = GetExtendedHeader(wxTarHeaderBlock::Name(id))) != wxEmptyString) {
+ if ((value = GetExtendedHeader(m_hdr->Name(id))) != wxEmptyString) {
wxTarNumber n = 0;
- const wxChar *p = value;
- while (*p == ' ')
+ wxString::const_iterator p = value.begin();
+ while (*p == ' ' && p != value.end())
p++;
while (isdigit(*p))
n = n * 10 + (*p++ - '0');
{
wxString value;
- if ((value = GetExtendedHeader(wxTarHeaderBlock::Name(id))) != wxEmptyString)
+ if ((value = GetExtendedHeader(m_hdr->Name(id))) != wxEmptyString)
return value;
return wxString(m_hdr->Get(id), GetConv());
if (end == wxString::npos || end + 1 >= format.length())
break;
ret << format.substr(begin, end - begin);
- switch (format[end + 1]) {
+ switch ( format[end + 1].GetValue() ) {
case 'd': ret << d; break;
case 'f': ret << f; break;
case 'p': ret << wxGetProcessId(); break;
originalPos = m_parent_o_stream->TellO();
if (originalPos != wxInvalidOffset)
sizePos =
- m_parent_o_stream->SeekO(m_headpos + wxTarHeaderBlock::Offset(TAR_SIZE));
+ m_parent_o_stream->SeekO(m_headpos + m_hdr->Offset(TAR_SIZE));
}
if (sizePos == wxInvalidOffset || !m_hdr->SetOctal(TAR_SIZE, m_pos)) {
m_chksum += m_hdr->SumField(TAR_SIZE);
m_hdr->SetOctal(TAR_CHKSUM, m_chksum);
- wxFileOffset sumPos = m_headpos + wxTarHeaderBlock::Offset(TAR_CHKSUM);
+ wxFileOffset sumPos = m_headpos + m_hdr->Offset(TAR_CHKSUM);
return
m_hdr->WriteField(*m_parent_o_stream, TAR_SIZE) &&
if (m_hdr->SetOctal(id, n)) {
return true;
} else {
- SetExtendedHeader(wxTarHeaderBlock::Name(id), wxLongLong(n).ToString());
+ SetExtendedHeader(m_hdr->Name(id), wxLongLong(n).ToString());
return false;
}
}
void wxTarOutputStream::SetHeaderString(int id, const wxString& str)
{
- strncpy(m_hdr->Get(id), str.mb_str(GetConv()), wxTarHeaderBlock::Len(id));
- if (str.length() > wxTarHeaderBlock::Len(id))
- SetExtendedHeader(wxTarHeaderBlock::Name(id), str);
+ strncpy(m_hdr->Get(id), str.mb_str(GetConv()), m_hdr->Len(id));
+ if (str.length() > m_hdr->Len(id))
+ SetExtendedHeader(m_hdr->Name(id), str);
}
void wxTarOutputStream::SetHeaderDate(const wxString& key,
const wxString& value)
{
if (m_pax) {
+#if wxUSE_UNICODE
+ const wxCharBuffer utf_key = key.utf8_str();
+ const wxCharBuffer utf_value = value.utf8_str();
+#else
const wxWX2WCbuf wide_key = key.wc_str(GetConv());
const wxCharBuffer utf_key = wxConvUTF8.cWC2MB(wide_key);
const wxWX2WCbuf wide_value = value.wc_str(GetConv());
const wxCharBuffer utf_value = wxConvUTF8.cWC2MB(wide_value);
+#endif // wxUSE_UNICODE/!wxUSE_UNICODE
// a small buffer to format the length field in
char buf[32];