/usr/include/wx-3.0/wx/tarstrm.h is in wx3.0-headers 3.0.0-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 | /////////////////////////////////////////////////////////////////////////////
// Name: wx/tarstrm.h
// Purpose: Streams for Tar files
// Author: Mike Wetherell
// Copyright: (c) 2004 Mike Wetherell
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_WXTARSTREAM_H__
#define _WX_WXTARSTREAM_H__
#include "wx/defs.h"
#if wxUSE_TARSTREAM
#include "wx/archive.h"
#include "wx/hashmap.h"
/////////////////////////////////////////////////////////////////////////////
// Constants
// TypeFlag values
enum wxTarType
{
wxTAR_REGTYPE = '0', // regular file
wxTAR_LNKTYPE = '1', // hard link
wxTAR_SYMTYPE = '2', // symbolic link
wxTAR_CHRTYPE = '3', // character special
wxTAR_BLKTYPE = '4', // block special
wxTAR_DIRTYPE = '5', // directory
wxTAR_FIFOTYPE = '6', // named pipe
wxTAR_CONTTYPE = '7' // contiguous file
};
// Archive Formats (use wxTAR_PAX, it's backward compatible)
enum wxTarFormat
{
wxTAR_USTAR, // POSIX.1-1990 tar format
wxTAR_PAX // POSIX.1-2001 tar format
};
/////////////////////////////////////////////////////////////////////////////
// wxTarNotifier
class WXDLLIMPEXP_BASE wxTarNotifier
{
public:
virtual ~wxTarNotifier() { }
virtual void OnEntryUpdated(class wxTarEntry& entry) = 0;
};
/////////////////////////////////////////////////////////////////////////////
// Tar Entry - hold the meta data for a file in the tar
class WXDLLIMPEXP_BASE wxTarEntry : public wxArchiveEntry
{
public:
wxTarEntry(const wxString& name = wxEmptyString,
const wxDateTime& dt = wxDateTime::Now(),
wxFileOffset size = wxInvalidOffset);
virtual ~wxTarEntry();
wxTarEntry(const wxTarEntry& entry);
wxTarEntry& operator=(const wxTarEntry& entry);
// Get accessors
wxString GetName(wxPathFormat format = wxPATH_NATIVE) const;
wxString GetInternalName() const { return m_Name; }
wxPathFormat GetInternalFormat() const { return wxPATH_UNIX; }
int GetMode() const;
int GetUserId() const { return m_UserId; }
int GetGroupId() const { return m_GroupId; }
wxFileOffset GetSize() const { return m_Size; }
wxFileOffset GetOffset() const { return m_Offset; }
wxDateTime GetDateTime() const { return m_ModifyTime; }
wxDateTime GetAccessTime() const { return m_AccessTime; }
wxDateTime GetCreateTime() const { return m_CreateTime; }
int GetTypeFlag() const { return m_TypeFlag; }
wxString GetLinkName() const { return m_LinkName; }
wxString GetUserName() const { return m_UserName; }
wxString GetGroupName() const { return m_GroupName; }
int GetDevMajor() const { return m_DevMajor; }
int GetDevMinor() const { return m_DevMinor; }
// is accessors
bool IsDir() const;
bool IsReadOnly() const { return !(m_Mode & 0222); }
// set accessors
void SetName(const wxString& name, wxPathFormat format = wxPATH_NATIVE);
void SetUserId(int id) { m_UserId = id; }
void SetGroupId(int id) { m_GroupId = id; }
void SetMode(int mode);
void SetSize(wxFileOffset size) { m_Size = size; }
void SetDateTime(const wxDateTime& dt) { m_ModifyTime = dt; }
void SetAccessTime(const wxDateTime& dt) { m_AccessTime = dt; }
void SetCreateTime(const wxDateTime& dt) { m_CreateTime = dt; }
void SetTypeFlag(int type) { m_TypeFlag = type; }
void SetLinkName(const wxString& link) { m_LinkName = link; }
void SetUserName(const wxString& user) { m_UserName = user; }
void SetGroupName(const wxString& group) { m_GroupName = group; }
void SetDevMajor(int dev) { m_DevMajor = dev; }
void SetDevMinor(int dev) { m_DevMinor = dev; }
// set is accessors
void SetIsDir(bool isDir = true);
void SetIsReadOnly(bool isReadOnly = true);
static wxString GetInternalName(const wxString& name,
wxPathFormat format = wxPATH_NATIVE,
bool *pIsDir = NULL);
wxTarEntry *Clone() const { return new wxTarEntry(*this); }
void SetNotifier(wxTarNotifier& WXUNUSED(notifier)) { }
private:
void SetOffset(wxFileOffset offset) { m_Offset = offset; }
virtual wxArchiveEntry* DoClone() const { return Clone(); }
wxString m_Name;
int m_Mode;
bool m_IsModeSet;
int m_UserId;
int m_GroupId;
wxFileOffset m_Size;
wxFileOffset m_Offset;
wxDateTime m_ModifyTime;
wxDateTime m_AccessTime;
wxDateTime m_CreateTime;
int m_TypeFlag;
wxString m_LinkName;
wxString m_UserName;
wxString m_GroupName;
int m_DevMajor;
int m_DevMinor;
friend class wxTarInputStream;
DECLARE_DYNAMIC_CLASS(wxTarEntry)
};
/////////////////////////////////////////////////////////////////////////////
// wxTarInputStream
WX_DECLARE_STRING_HASH_MAP(wxString, wxTarHeaderRecords);
class WXDLLIMPEXP_BASE wxTarInputStream : public wxArchiveInputStream
{
public:
typedef wxTarEntry entry_type;
wxTarInputStream(wxInputStream& stream, wxMBConv& conv = wxConvLocal);
wxTarInputStream(wxInputStream *stream, wxMBConv& conv = wxConvLocal);
virtual ~wxTarInputStream();
bool OpenEntry(wxTarEntry& entry);
bool CloseEntry();
wxTarEntry *GetNextEntry();
wxFileOffset GetLength() const { return m_size; }
bool IsSeekable() const { return m_parent_i_stream->IsSeekable(); }
protected:
size_t OnSysRead(void *buffer, size_t size);
wxFileOffset OnSysTell() const { return m_pos; }
wxFileOffset OnSysSeek(wxFileOffset seek, wxSeekMode mode);
private:
void Init();
wxArchiveEntry *DoGetNextEntry() { return GetNextEntry(); }
bool OpenEntry(wxArchiveEntry& entry);
bool IsOpened() const { return m_pos != wxInvalidOffset; }
wxStreamError ReadHeaders();
bool ReadExtendedHeader(wxTarHeaderRecords*& recs);
wxString GetExtendedHeader(const wxString& key) const;
wxString GetHeaderPath() const;
wxFileOffset GetHeaderNumber(int id) const;
wxString GetHeaderString(int id) const;
wxDateTime GetHeaderDate(const wxString& key) const;
wxFileOffset m_pos; // position within the current entry
wxFileOffset m_offset; // offset to the start of the entry's data
wxFileOffset m_size; // size of the current entry's data
int m_sumType;
int m_tarType;
class wxTarHeaderBlock *m_hdr;
wxTarHeaderRecords *m_HeaderRecs;
wxTarHeaderRecords *m_GlobalHeaderRecs;
wxDECLARE_NO_COPY_CLASS(wxTarInputStream);
};
/////////////////////////////////////////////////////////////////////////////
// wxTarOutputStream
class WXDLLIMPEXP_BASE wxTarOutputStream : public wxArchiveOutputStream
{
public:
wxTarOutputStream(wxOutputStream& stream,
wxTarFormat format = wxTAR_PAX,
wxMBConv& conv = wxConvLocal);
wxTarOutputStream(wxOutputStream *stream,
wxTarFormat format = wxTAR_PAX,
wxMBConv& conv = wxConvLocal);
virtual ~wxTarOutputStream();
bool PutNextEntry(wxTarEntry *entry);
bool PutNextEntry(const wxString& name,
const wxDateTime& dt = wxDateTime::Now(),
wxFileOffset size = wxInvalidOffset);
bool PutNextDirEntry(const wxString& name,
const wxDateTime& dt = wxDateTime::Now());
bool CopyEntry(wxTarEntry *entry, wxTarInputStream& inputStream);
bool CopyArchiveMetaData(wxTarInputStream& WXUNUSED(s)) { return true; }
void Sync();
bool CloseEntry();
bool Close();
bool IsSeekable() const { return m_parent_o_stream->IsSeekable(); }
void SetBlockingFactor(int factor) { m_BlockingFactor = factor; }
int GetBlockingFactor() const { return m_BlockingFactor; }
protected:
size_t OnSysWrite(const void *buffer, size_t size);
wxFileOffset OnSysTell() const { return m_pos; }
wxFileOffset OnSysSeek(wxFileOffset pos, wxSeekMode mode);
private:
void Init(wxTarFormat format);
bool PutNextEntry(wxArchiveEntry *entry);
bool CopyEntry(wxArchiveEntry *entry, wxArchiveInputStream& stream);
bool CopyArchiveMetaData(wxArchiveInputStream& WXUNUSED(s)) { return true; }
bool IsOpened() const { return m_pos != wxInvalidOffset; }
bool WriteHeaders(wxTarEntry& entry);
bool ModifyHeader();
wxString PaxHeaderPath(const wxString& format, const wxString& path);
void SetExtendedHeader(const wxString& key, const wxString& value);
void SetHeaderPath(const wxString& name);
bool SetHeaderNumber(int id, wxFileOffset n);
void SetHeaderString(int id, const wxString& str);
void SetHeaderDate(const wxString& key, const wxDateTime& datetime);
wxFileOffset m_pos; // position within the current entry
wxFileOffset m_maxpos; // max pos written
wxFileOffset m_size; // expected entry size
wxFileOffset m_headpos; // offset within the file to the entry's header
wxFileOffset m_datapos; // offset within the file to the entry's data
wxFileOffset m_tarstart;// offset within the file to the tar
wxFileOffset m_tarsize; // size of tar so far
bool m_pax;
int m_BlockingFactor;
wxUint32 m_chksum;
bool m_large;
class wxTarHeaderBlock *m_hdr;
class wxTarHeaderBlock *m_hdr2;
char *m_extendedHdr;
size_t m_extendedSize;
wxString m_badfit;
bool m_endrecWritten;
wxDECLARE_NO_COPY_CLASS(wxTarOutputStream);
};
/////////////////////////////////////////////////////////////////////////////
// Iterators
#if wxUSE_STL || defined WX_TEST_ARCHIVE_ITERATOR
typedef wxArchiveIterator<wxTarInputStream> wxTarIter;
typedef wxArchiveIterator<wxTarInputStream,
std::pair<wxString, wxTarEntry*> > wxTarPairIter;
#endif
/////////////////////////////////////////////////////////////////////////////
// wxTarClassFactory
class WXDLLIMPEXP_BASE wxTarClassFactory : public wxArchiveClassFactory
{
public:
typedef wxTarEntry entry_type;
typedef wxTarInputStream instream_type;
typedef wxTarOutputStream outstream_type;
typedef wxTarNotifier notifier_type;
#if wxUSE_STL || defined WX_TEST_ARCHIVE_ITERATOR
typedef wxTarIter iter_type;
typedef wxTarPairIter pairiter_type;
#endif
wxTarClassFactory();
wxTarEntry *NewEntry() const
{ return new wxTarEntry; }
wxTarInputStream *NewStream(wxInputStream& stream) const
{ return new wxTarInputStream(stream, GetConv()); }
wxTarOutputStream *NewStream(wxOutputStream& stream) const
{ return new wxTarOutputStream(stream, wxTAR_PAX, GetConv()); }
wxTarInputStream *NewStream(wxInputStream *stream) const
{ return new wxTarInputStream(stream, GetConv()); }
wxTarOutputStream *NewStream(wxOutputStream *stream) const
{ return new wxTarOutputStream(stream, wxTAR_PAX, GetConv()); }
wxString GetInternalName(const wxString& name,
wxPathFormat format = wxPATH_NATIVE) const
{ return wxTarEntry::GetInternalName(name, format); }
const wxChar * const *GetProtocols(wxStreamProtocolType type
= wxSTREAM_PROTOCOL) const;
protected:
wxArchiveEntry *DoNewEntry() const
{ return NewEntry(); }
wxArchiveInputStream *DoNewStream(wxInputStream& stream) const
{ return NewStream(stream); }
wxArchiveOutputStream *DoNewStream(wxOutputStream& stream) const
{ return NewStream(stream); }
wxArchiveInputStream *DoNewStream(wxInputStream *stream) const
{ return NewStream(stream); }
wxArchiveOutputStream *DoNewStream(wxOutputStream *stream) const
{ return NewStream(stream); }
private:
DECLARE_DYNAMIC_CLASS(wxTarClassFactory)
};
#endif // wxUSE_TARSTREAM
#endif // _WX_WXTARSTREAM_H__
|