Switchboard SDK
Loading...
Searching...
No Matches
switchboard::audio::ZipFile Class Reference

Public Member Functions

 ZipFile (const std::string &path, bool read=true)
 
bool add (const std::string &path, const std::string &name)
 
bool add (const std::vector< uint8 > &data, const std::string &name)
 
bool addFile (const std::string &name, const std::string &contents)
 
bool save ()
 
std::pair< bool, std::string > test ()
 
bool hasFile (const std::string &name) const
 
std::vector< uint8 > getFile (const std::string &name) const
 
int getNumFiles () const
 

Constructor & Destructor Documentation

◆ ZipFile()

switchboard::audio::ZipFile::ZipFile ( const std::string & path,
bool read = true )

The class constructor.

Parameters
pathDestination of the zip file.

Member Function Documentation

◆ add() [1/2]

bool switchboard::audio::ZipFile::add ( const std::string & path,
const std::string & name )

Adds existing file to the zip.

Parameters
pathPath fo the file to add.
nameName to appear in the zip file.
Returns
True - success, false - failure.

◆ add() [2/2]

bool switchboard::audio::ZipFile::add ( const std::vector< uint8 > & data,
const std::string & name )

Adds binary data to the zip.

Parameters
dataThe Binary Data to add to the zip file.
nameName to appear in the zip file.
Returns
True - success, false - failure.

◆ addFile()

bool switchboard::audio::ZipFile::addFile ( const std::string & name,
const std::string & contents )

Adds text file to the zip.

Parameters
nameName to appear in the zip file.
contentsContents of the file.
Returns
True - success, false - failure.

◆ getFile()

std::vector< uint8 > switchboard::audio::ZipFile::getFile ( const std::string & name) const

Return contents of a file in the zip.

Parameters
nameName of file.
Returns
Contents of the file.

◆ getNumFiles()

int switchboard::audio::ZipFile::getNumFiles ( ) const

Get number of files in the zip.

Returns
Number of files.

◆ hasFile()

bool switchboard::audio::ZipFile::hasFile ( const std::string & name) const

Check if a file exists in the zip.

Parameters
nameName of file.
Returns
True - success, false - failure.

◆ save()

bool switchboard::audio::ZipFile::save ( void )

Save the zip file.

Returns
True - success, false - failure.

◆ test()

std::pair< bool, std::string > switchboard::audio::ZipFile::test ( )

Test the zip file.