TarEntry Class Reference

#include <Pt/System/TarEntry.h>

Represents a single entry returned by TarReader. More...

Public Types

enum  Type {
  Invalid = 0,
  File = 1,
  Directory = 2,
  Link = 3,
  Hardlink = 4
}
 Entry type in the tar archive. More...
 

Public Member Functions

 TarEntry ()=default
 Default constructor.
 
 TarEntry (TarEntry &&)=default
 Move constructor.
 
TarEntryoperator= (TarEntry &&)=default
 Move assignment.
 
 ~TarEntry ()=default
 Destructor.
 
void clear ()
 Resets all fields to their default values.
 
bool isEnd () const
 Returns true when the entire content has been delivered. More...
 
const Pt::System::Pathpath () const
 Archive path of this entry (UTF-8 encoded).
 
std::size_t size () const
 Total content size in bytes as stored in the archive header.
 
std::size_t remaining () const
 Content bytes not yet delivered by TarReader::advance().
 
std::size_t avail () const
 Number of bytes readable at the current data() pointer.
 
const char * data () const
 Pointer to the current content chunk of avail() bytes. More...
 
Type type () const
 Type of this archive entry (file, directory, link, or hard link).
 
const Pt::System::PathlinkTarget () const
 Target path for symbolic and hard links (UTF-8 encoded).
 
Pt::System::FileInfo::Perms permissions () const
 POSIX permission bits for this entry.
 
const Pt::DateTimemtime () const
 Last modification time of this entry.
 
void setPath (const Pt::System::Path &path)
 Sets the archive path.
 
void setSize (std::size_t size)
 Sets the total content size in bytes.
 
void setRemaining (std::size_t remaining)
 Sets the number of content bytes not yet delivered.
 
void setData (const char *data, std::size_t avail)
 Sets the current data chunk pointer and the number of available bytes.
 
void setType (Type type)
 Sets the entry type.
 
void setLinkTarget (const Pt::System::Path &target)
 Sets the link target path.
 
void setPermissions (Pt::System::FileInfo::Perms p)
 Sets the POSIX permission bits.
 
void setMtime (const Pt::DateTime &mtime)
 Sets the modification time.
 

Detailed Description

A TarEntry holds the metadata and provides access to the content of one entry in a tar archive. Instances are produced by TarReader::advance() and remain valid until the next advance() call.

Use type() to distinguish files, directories, symbolic links, and hard links. Use path() for the archive path, mtime() for the modification time, and permissions() for the POSIX permission bits.

File content is delivered in one or more chunks. After each advance() call, up to avail() bytes are readable at data(). Process those bytes before calling advance() again — the buffer is reused on the next call. Repeat until isEnd() returns true, which means all size() bytes have been delivered.

Member Enumeration Documentation

◆ Type

enum Type
Enumerator
Invalid 

Not yet set.

File 

Regular file.

Directory 

Directory.

Link 

Symbolic link.

Hardlink 

Hard link.

Member Function Documentation

◆ isEnd()

bool isEnd ( ) const

Once this returns true, the next TarReader::advance() call moves to the following archive entry.

◆ data()

const char* data ( ) const

Process these bytes before calling TarReader::advance() again — the pointer becomes invalid on the next advance() call.