Version: 3.1.0
wxTarOutputStream Class Reference

#include <wx/tarstrm.h>

+ Inheritance diagram for wxTarOutputStream:

Detailed Description

Output stream for writing tar files.

wxTarOutputStream::PutNextEntry() is used to create a new entry in the output tar, then the entry's data is written to the wxTarOutputStream. Another call to wxTarOutputStream::PutNextEntry() closes the current entry and begins the next.

Library:  wxBase
Category:  Streams
See Also
Archive Formats, wxTarEntry, wxTarInputStream

Public Member Functions

virtual ~wxTarOutputStream ()
 The destructor calls Close() to finish writing the tar if it has not been called already.
 
bool Close ()
 Finishes writing the tar, returning true if successful.
 
bool CloseEntry ()
 Close the current entry.
 
bool CopyArchiveMetaData (wxTarInputStream &s)
 See wxArchiveOutputStream::CopyArchiveMetaData().
 
bool CopyEntry (wxTarEntry *entry, wxTarInputStream &inputStream)
 Takes ownership of entry and uses it to create a new entry in the tar.
 
bool PutNextDirEntry (const wxString &name, const wxDateTime &dt=wxDateTime::Now())
 Create a new directory entry (see wxArchiveEntry::IsDir()) with the given name and timestamp.
 
bool PutNextEntry (wxTarEntry *entry)
 Takes ownership of entry and uses it to create a new entry in the tar.
 
bool PutNextEntry (const wxString &name, const wxDateTime &dt=wxDateTime::Now(), wxFileOffset size=wxInvalidOffset)
 Create a new entry with the given name, timestamp and size.
 
 wxTarOutputStream (wxOutputStream &stream, wxTarFormat format=wxTAR_PAX, wxMBConv &conv=wxConvLocal)
 If the parent stream is passed as a pointer then the new filter stream takes ownership of it.
 
 wxTarOutputStream (wxOutputStream *stream, wxTarFormat format=wxTAR_PAX, wxMBConv &conv=wxConvLocal)
 If the parent stream is passed as a pointer then the new filter stream takes ownership of it.
 
int GetBlockingFactor () const
 The tar is zero padded to round its size up to BlockingFactor * 512 bytes.
 
void SetBlockingFactor (int factor)
 The tar is zero padded to round its size up to BlockingFactor * 512 bytes.
 
- Public Member Functions inherited from wxArchiveOutputStream
virtual ~wxArchiveOutputStream ()
 Calls Close() if it has not already been called.
 
virtual bool CopyArchiveMetaData (wxArchiveInputStream &stream)=0
 Some archive formats have additional meta-data that applies to the archive as a whole.
 
virtual bool CopyEntry (wxArchiveEntry *entry, wxArchiveInputStream &stream)=0
 Takes ownership of entry and uses it to create a new entry in the archive.
 
virtual bool PutNextEntry (wxArchiveEntry *entry)=0
 Takes ownership of entry and uses it to create a new entry in the archive.
 
- Public Member Functions inherited from wxFilterOutputStream
 wxFilterOutputStream (wxOutputStream &stream)
 Initializes a "filter" stream.
 
 wxFilterOutputStream (wxOutputStream *stream)
 Initializes a "filter" stream.
 
- Public Member Functions inherited from wxOutputStream
 wxOutputStream ()
 Creates a dummy wxOutputStream object.
 
virtual ~wxOutputStream ()
 Destructor.
 
virtual size_t LastWrite () const
 Returns the number of bytes written during the last Write().
 
void PutC (char c)
 Puts the specified character in the output queue and increments the stream position.
 
virtual wxFileOffset SeekO (wxFileOffset pos, wxSeekMode mode=wxFromStart)
 Changes the stream current position.
 
virtual wxFileOffset TellO () const
 Returns the current stream position.
 
virtual wxOutputStreamWrite (const void *buffer, size_t size)
 Writes up to the specified amount of bytes using the data of buffer.
 
wxOutputStreamWrite (wxInputStream &stream_in)
 Reads data from the specified input stream and stores them in the current stream.
 
bool WriteAll (const void *buffer, size_t size)
 Writes exactly the specified number of bytes from the buffer.
 
- Public Member Functions inherited from wxStreamBase
 wxStreamBase ()
 Creates a dummy stream object.
 
virtual ~wxStreamBase ()
 Destructor.
 
wxStreamError GetLastError () const
 This function returns the last error.
 
virtual wxFileOffset GetLength () const
 Returns the length of the stream in bytes.
 
virtual size_t GetSize () const
 This function returns the size of the stream.
 
virtual bool IsOk () const
 Returns true if no error occurred on the stream.
 
virtual bool IsSeekable () const
 Returns true if the stream supports seeking to arbitrary offsets.
 
void Reset (wxStreamError error=wxSTREAM_NO_ERROR)
 Resets the stream state.
 
bool operator! () const
 Returns the opposite of IsOk().
 

Additional Inherited Members

- Protected Member Functions inherited from wxOutputStream
size_t OnSysWrite (const void *buffer, size_t bufsize)
 Internal function.
 

Constructor & Destructor Documentation

wxTarOutputStream::wxTarOutputStream ( wxOutputStream stream,
wxTarFormat  format = wxTAR_PAX,
wxMBConv conv = wxConvLocal 
)

If the parent stream is passed as a pointer then the new filter stream takes ownership of it.

If it is passed by reference then it does not.

In a Unicode build the third parameter conv is used to translate the headers fields into an 8-bit encoding. It has no effect on the stream's data.

When the format is wxTAR_PAX, pax extended headers are generated when any header field will not fit the standard tar header block or if it uses any non-ascii characters.

Extended headers are stored as extra 'files' within the tar, and will be extracted as such by any other tar program that does not understand them. The conv parameter only affect the standard tar headers, the extended headers are always UTF-8 encoded.

When the format is wxTAR_USTAR, no extended headers are generated, and instead a warning message is logged if any header field overflows.

wxTarOutputStream::wxTarOutputStream ( wxOutputStream stream,
wxTarFormat  format = wxTAR_PAX,
wxMBConv conv = wxConvLocal 
)

If the parent stream is passed as a pointer then the new filter stream takes ownership of it.

If it is passed by reference then it does not.

In a Unicode build the third parameter conv is used to translate the headers fields into an 8-bit encoding. It has no effect on the stream's data.

When the format is wxTAR_PAX, pax extended headers are generated when any header field will not fit the standard tar header block or if it uses any non-ascii characters.

Extended headers are stored as extra 'files' within the tar, and will be extracted as such by any other tar program that does not understand them. The conv parameter only affect the standard tar headers, the extended headers are always UTF-8 encoded.

When the format is wxTAR_USTAR, no extended headers are generated, and instead a warning message is logged if any header field overflows.

virtual wxTarOutputStream::~wxTarOutputStream ( )
virtual

The destructor calls Close() to finish writing the tar if it has not been called already.

Member Function Documentation

bool wxTarOutputStream::Close ( )
virtual

Finishes writing the tar, returning true if successful.

Called by the destructor if not called explicitly.

Reimplemented from wxArchiveOutputStream.

bool wxTarOutputStream::CloseEntry ( )
virtual

Close the current entry.

It is called implicitly whenever another new entry is created with CopyEntry() or PutNextEntry(), or when the tar is closed.

Implements wxArchiveOutputStream.

bool wxTarOutputStream::CopyArchiveMetaData ( wxTarInputStream s)

See wxArchiveOutputStream::CopyArchiveMetaData().

For the tar format this function does nothing.

bool wxTarOutputStream::CopyEntry ( wxTarEntry entry,
wxTarInputStream inputStream 
)

Takes ownership of entry and uses it to create a new entry in the tar.

entry is then opened in inputStream and its contents copied to this stream.

For some other archive formats CopyEntry() is much more efficient than transferring the data using Read() and Write() since it will copy them without decompressing and recompressing them. For tar however it makes no difference.

For tars on seekable streams, entry must be from the same tar file as inputStream. For non-seekable streams, entry must also be the last thing read from inputStream.

int wxTarOutputStream::GetBlockingFactor ( ) const

The tar is zero padded to round its size up to BlockingFactor * 512 bytes.

The blocking factor defaults to 10 for wxTAR_PAX and 20 for wxTAR_USTAR (see wxTarOutputStream()), as specified in the POSIX standards.

bool wxTarOutputStream::PutNextDirEntry ( const wxString name,
const wxDateTime dt = wxDateTime::Now() 
)
virtual

Create a new directory entry (see wxArchiveEntry::IsDir()) with the given name and timestamp.

PutNextEntry() can also be used to create directory entries, by supplying a name with a trailing path separator.

Implements wxArchiveOutputStream.

bool wxTarOutputStream::PutNextEntry ( wxTarEntry entry)

Takes ownership of entry and uses it to create a new entry in the tar.

bool wxTarOutputStream::PutNextEntry ( const wxString name,
const wxDateTime dt = wxDateTime::Now(),
wxFileOffset  size = wxInvalidOffset 
)
virtual

Create a new entry with the given name, timestamp and size.

Implements wxArchiveOutputStream.

void wxTarOutputStream::SetBlockingFactor ( int  factor)

The tar is zero padded to round its size up to BlockingFactor * 512 bytes.

The blocking factor defaults to 10 for wxTAR_PAX and 20 for wxTAR_USTAR (see wxTarOutputStream()), as specified in the POSIX standards.