sptk2 logo
SPTK Home Page
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
sptk::ArchiveFile Class Reference

File inside tar archive. More...

#include <ArchiveFile.h>

Inheritance diagram for sptk::ArchiveFile:
sptk::Buffer sptk::BufferStorage

Classes

struct  Ownership
 

Public Types

enum class  Type : uint8_t {
  REGULAR_FILE = '0' , REGULAR_FILE2 = '\0' , HARD_LINK = '1' , SYM_LINK = '2' ,
  CHARACTER = '3' , BLOCK = '4' , DIRECTORY = '5' , FIFO = '6' ,
  CONTTYPE = '7'
}
 File type for file inside tar archive. More...
 

Public Member Functions

 ArchiveFile (const fs::path &fileName, const fs::path &baseDirectory)
 Constructor. More...
 
 ArchiveFile (const fs::path &fileName, const Buffer &content, int mode, const DateTime &mtime, ArchiveFile::Type type, const Ownership &ownership, const fs::path &linkName)
 Constructor. More...
 
const char * header () const
 Actual tar file header, length is TAR_BLOCK_SIZE. More...
 
String fileName () const
 
unsigned mode () const
 
const Ownershipownership () const
 
unsigned size () const
 
DateTime mtime () const
 
Type type () const
 
String linkname () const
 
- Public Member Functions inherited from sptk::Buffer
 Buffer (const String &str)
 
 Buffer (const Buffer &other)=default
 
 Buffer (Buffer &&other) noexcept=default
 
 ~Buffer () noexcept override=default
 
Bufferoperator= (Buffer &&other) DOESNT_THROW=default
 
Bufferoperator= (const Buffer &other)=default
 
void append (char ch) override
 
void append (const char *data, size_t sz=0) override
 
void append (const uint8_t *data, size_t sz) override
 
template<class T >
void append (T val)
 
void append (const std::string &str)
 
void append (const String &str)
 
void append (const Buffer &buffer)
 
uint8_t & operator[] (size_t index)
 
const uint8_t & operator[] (size_t index) const
 
bool operator== (const Buffer &other) const
 
bool operator!= (const Buffer &other) const
 
void loadFromFile (const fs::path &fileName)
 
void saveToFile (const fs::path &fileName) const
 
Bufferoperator= (const String &str)
 
Bufferoperator= (const char *str)
 
 operator String () const
 
 BufferStorage ()
 
 BufferStorage (size_t sz)
 
 BufferStorage (const BufferStorage &bufferStorage)=default
 
 BufferStorage (BufferStorage &&bufferStorage) noexcept=default
 
template<typename T >
 BufferStorage (const T *data, size_t sz)
 
- Public Member Functions inherited from sptk::BufferStorage
 BufferStorage ()
 
 BufferStorage (size_t sz)
 
 BufferStorage (const BufferStorage &bufferStorage)=default
 
 BufferStorage (BufferStorage &&bufferStorage) noexcept=default
 
virtual ~BufferStorage ()=default
 
BufferStorageoperator= (const BufferStorage &bufferStorage)=default
 
BufferStorageoperator= (BufferStorage &&bufferStorage) noexcept=default
 
template<typename T >
 BufferStorage (const T *data, size_t sz)
 
uint8_t * data ()
 
const uint8_t * data () const
 
const char * c_str () const
 
bool empty () const
 
virtual void checkSize (size_t sz)
 
template<typename T >
void set (const T *data, size_t sz)
 
void set (const BufferStorage &data)
 
void set (const String &data)
 
size_t capacity () const
 
size_t length () const
 
size_t bytes () const
 
void bytes (size_t b)
 
virtual void append (char ch)
 
virtual void append (const char *data, size_t sz=0)
 
virtual void append (const uint8_t *data, size_t sz)
 
void reset (size_t sz=0)
 
void fill (char ch, size_t count)
 
void erase (size_t offset, size_t length)
 

Static Public Member Functions

static fs::path relativePath (const fs::path &fileName, const fs::path &baseDirectory)
 

Additional Inherited Members

- Protected Member Functions inherited from sptk::BufferStorage
void adjustSize (size_t sz)
 
void allocate (size_t size)
 
void allocate (const uint8_t *data, size_t size)
 
void reallocate (size_t size)
 
void deallocate () noexcept
 
void init (const uint8_t *data, size_t size, size_t bytes)
 

Detailed Description

File inside tar archive.

Member Enumeration Documentation

◆ Type

enum class sptk::ArchiveFile::Type : uint8_t
strong

File type for file inside tar archive.

Enumerator
REGULAR_FILE 

Regular file (preferred code).

REGULAR_FILE2 

Regular file (alternate code).

HARD_LINK 

Hard link.

SYM_LINK 

Symbolic link (hard if not supported).

CHARACTER 

Character special.

BLOCK 

Block special.

DIRECTORY 

Directory.

FIFO 

Named pipe.

CONTTYPE 

Contiguous file (regular file if not supported).

Constructor & Destructor Documentation

◆ ArchiveFile() [1/2]

sptk::ArchiveFile::ArchiveFile ( const fs::path &  fileName,
const fs::path &  baseDirectory 
)
explicit

Constructor.

Parameters
fileNameFile name
baseDirectoryDirectory used as a base for relative path for files inside archive

◆ ArchiveFile() [2/2]

sptk::ArchiveFile::ArchiveFile ( const fs::path &  fileName,
const Buffer content,
int  mode,
const DateTime mtime,
ArchiveFile::Type  type,
const Ownership ownership,
const fs::path &  linkName 
)

Constructor.

Parameters
fileNameFile name
contentFile data (regular files only)
modeFile mode, i.e. 0640
mtimeModification time
typeFile type
ownershipFile owners
linkNameName the link is pointing to

Member Function Documentation

◆ header()

const char * sptk::ArchiveFile::header ( ) const

Actual tar file header, length is TAR_BLOCK_SIZE.

Returns
Actual tar file header data

The documentation for this class was generated from the following file:

Fri Oct 14 2022 09:58:32: SPTK 5.4.1