Ult3D
Implementation of "Ultimate 3D Game Engine Design & Architecture" by Allan Sherrod
Loading...
Searching...
No Matches
Ult::Archive Class Reference

#include <Archive.h>

Public Member Functions

 Archive ()
 
virtual ~Archive ()
 
bool ReadArchiveFile (const char *fileName)
 
bool WriteArchiveFile (const char *fileName, ArchiveFileHeader *headers, const int totalHeaders)
 
void CloseArchive ()
 
bool Extract (int index, char *location)
 
bool Extract (const char *fileName, char *location)
 
int GetFileIndex (const char *fileName)
 
bool GetFileData (int index, char *buffer, int bytesToRead)
 
bool GetFileData (const char *fileName, char *buffer, int bytesToRead)
 
bool GetFileHeaderInfoByIndex (int index, ArchiveFileHeader *fh)
 
int GetTotalHeaders () const
 
bool IsArchiveOpen () const
 

Detailed Description

Represents a custom binary structure containing multiple files and a header.

Constructor & Destructor Documentation

◆ Archive()

Ult::Archive::Archive ( )

Archive constructor.

◆ ~Archive()

Ult::Archive::~Archive ( )
virtual

Archive destructor.

Member Function Documentation

◆ CloseArchive()

void Ult::Archive::CloseArchive ( )

Frees all headers and closes any opened files.

◆ Extract() [1/2]

bool Ult::Archive::Extract ( const char * fileName,
char * location )

Calculate the file index based on fileName and call Extract on it.

◆ Extract() [2/2]

bool Ult::Archive::Extract ( int index,
char * location )

Copy the file data at the given index into a new file.

Parameters
locationThe filename of the new extracted file.
Returns
True on success, false on failure.

◆ GetFileData() [1/2]

bool Ult::Archive::GetFileData ( const char * fileName,
char * buffer,
int bytesToRead )

Calcaulte the file index based on fileName and call GetFileData on it.

◆ GetFileData() [2/2]

bool Ult::Archive::GetFileData ( int index,
char * buffer,
int bytesToRead )

Copy the data of the file given by index into buffer.

Parameters
bytesToReadthe number of bytes to copy from the file.
Returns
True on success, false on failure.

◆ GetFileHeaderInfoByIndex()

bool Ult::Archive::GetFileHeaderInfoByIndex ( int index,
ArchiveFileHeader * fh )

Store the archive file header data of the file at the given index into fh.

Returns
True on success, false on failure.

◆ GetFileIndex()

int Ult::Archive::GetFileIndex ( const char * fileName)

Get the index of the file given by fileName.

◆ GetTotalHeaders()

int Ult::Archive::GetTotalHeaders ( ) const
inline

Returns the total number of files contained in the archive.

◆ IsArchiveOpen()

bool Ult::Archive::IsArchiveOpen ( ) const
inline

Returns whether the archive file has been opened.

◆ ReadArchiveFile()

bool Ult::Archive::ReadArchiveFile ( const char * fileName)

Open and parse the archive file with the given file name.

Returns
True on success, false on failure.

◆ WriteArchiveFile()

bool Ult::Archive::WriteArchiveFile ( const char * fileName,
ArchiveFileHeader * headers,
const int totalHeaders )

Combine the data given by headers into a binary file on disk given by fileName.

Returns
True on success, false on failure.

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