SMTK
@SMTK_VERSION@
Simulation Modeling Tool Kit
|
A class for handling SMTK archives. More...
#include <Archive.h>
Classes | |
struct | Internals |
Public Member Functions | |
Archive (const std::string &archivePath) | |
Construct a new archive or access an existing archive at a given file path. | |
bool | insert (const std::string &filePath, const std::string &archivedPath) |
Add a file (identified by its path) to the archive. More... | |
bool | archive () const |
Serialize the files that comprise the archive to a contiguous block of memory on disk (located at archivePath ). More... | |
bool | extract () |
Deserialize the files that comprise the archive into a temporary directory for access via streams. More... | |
std::set< std::string > | contents () const |
Acquire a collection of archived file paths from the archive. This method. | |
std::ifstream | get (const std::string &archivedFilePath) |
Acquire a stream to a file in the archive, accessed by its archived file path. More... | |
void | get (const std::string &archivedFilePath, std::ifstream &) |
Acquire a stream to a file in the archive, accessed by its archived file path. More... | |
std::string | location (const std::string &archivedFilePath) |
Acquire the path to the file in the archive, accessed by its archived file path. More... | |
Static Public Member Functions | |
static bool | isArchive (const std::string &archivePath) |
Check if the input file located at <archivePath> is an archive. | |
A class for handling SMTK archives.
An SMTK Archive is a portable collection of files that are stored as a single file on-disk. An archive is described by its filesystem path. Once instantiated, a user can insert files into the archive, serialize/deserialize the archive to/from disk, access a list of files in the archive, and acquire file streams to these files by accessing them via their name. An archive can be considered a directory containing files; as such, each file in the archive must be assigned a unique path.
bool smtk::common::Archive::archive | ( | ) | const |
Serialize the files that comprise the archive to a contiguous block of memory on disk (located at archivePath ).
Return true upon success.
bool smtk::common::Archive::extract | ( | ) |
Deserialize the files that comprise the archive into a temporary directory for access via streams.
If a stream is requested from an unextracted archive, the archive is automatically extracted prior to returning the stream. Return true upon success.
std::ifstream smtk::common::Archive::get | ( | const std::string & | archivedFilePath | ) |
Acquire a stream to a file in the archive, accessed by its archived file path.
This method cannot be used on GCC < 5 due to a bug (see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53626). However, since we put paths where they should be and not where people walk, this API will remain in place.
void smtk::common::Archive::get | ( | const std::string & | archivedFilePath, |
std::ifstream & | stream | ||
) |
Acquire a stream to a file in the archive, accessed by its archived file path.
This method is functionally equivalent to the above get() method, but is provided as a workaround for a bug in GCC <5 (see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53626).
bool smtk::common::Archive::insert | ( | const std::string & | filePath, |
const std::string & | archivedPath | ||
) |
Add a file (identified by its path) to the archive.
Once in the archive, a stream to the file is accessible using the file's archived path. Each file in the archive must therefore have a unique path. Return true upon success.
std::string smtk::common::Archive::location | ( | const std::string & | archivedFilePath | ) |
Acquire the path to the file in the archive, accessed by its archived file path.
Return the empty string if the archived file path is not in the archive.