Abstract base class representing a mounted archive (OTR, O2R, or folder).
More...
#include <Archive.h>
|
| | Archive (const std::string &path, std::shared_ptr< ResourceManager > resourceManager=nullptr, std::shared_ptr< Keystore > keystore=nullptr) |
| | Constructs an Archive for the given filesystem path.
|
| |
| | ~Archive () |
| |
| bool | operator== (const Archive &rhs) const |
| | Two archives are equal when they refer to the same underlying path.
|
| |
| void | Load () |
| | Opens and indexes the archive, making its contents available for loading.
|
| |
| void | Unload () |
| | Closes the archive and releases all associated resources.
|
| |
| virtual std::shared_ptr< File > | LoadFile (const std::string &filePath)=0 |
| | Loads a file by its virtual path.
|
| |
| virtual std::shared_ptr< File > | LoadFile (uint64_t hash)=0 |
| | Loads a file by its 64-bit content hash.
|
| |
| std::shared_ptr< std::unordered_map< uint64_t, std::string > > | ListFiles () |
| | Returns a map of all files indexed in this archive (hash → path).
|
| |
| std::shared_ptr< std::unordered_map< uint64_t, std::string > > | ListFiles (const std::string &filter) |
| | Returns only the files whose paths match the given filter string.
|
| |
| bool | HasFile (const std::string &filePath) |
| | Checks whether the archive contains a file at the given path.
|
| |
| bool | HasFile (uint64_t hash) |
| | Checks whether the archive contains a file with the given hash.
|
| |
| bool | HasGameVersion () |
| | Returns true if a game version value was found in the manifest.
|
| |
| uint32_t | GetGameVersion () |
| | Returns the game version encoded in the archive manifest.
|
| |
| const ArchiveManifest & | GetManifest () |
| | Returns the parsed archive manifest.
|
| |
| bool | IsSigned () |
| | Returns true if the archive carries a digital signature in its manifest.
|
| |
| bool | IsChecksumValid () |
| | Returns true if the archive's checksum field matches the computed checksum.
|
| |
| const std::string & | GetPath () |
| | Returns the filesystem path this archive was opened from.
|
| |
| bool | IsInitialized () |
| | Returns true if the archive has been successfully initialized/opened.
|
| |
| virtual bool | Open ()=0 |
| | Opens the underlying archive file or directory for reading.
|
| |
| virtual bool | Close ()=0 |
| | Closes the underlying archive file or directory.
|
| |
| virtual bool | WriteFile (const std::string &filename, const std::vector< uint8_t > &data)=0 |
| | Writes raw data into the archive at the given path.
|
| |
|
| void | SetInitialized (bool isInitialized) |
| | Sets the initialized state flag. Called by Load() / Unload().
|
| |
| void | SetGameVersion (uint32_t gameVersion) |
| | Stores the game version parsed from the manifest.
|
| |
| void | IndexFile (const std::string &filePath) |
| | Adds a file to the internal hash→path index.
|
| |
| void | Validate () |
| | Validates the manifest checksum and signature, setting mIsSigned / mIsChecksumValid.
|
| |
Abstract base class representing a mounted archive (OTR, O2R, or folder).
An Archive encapsulates a collection of virtual files addressable by path or 64-bit hash. Concrete subclasses (OtrArchive, O2rArchive, FolderArchive) implement the platform- and format-specific I/O logic.
Archives are managed by ArchiveManager, which distributes load requests across all currently mounted archives.
◆ Archive()
| Ship::Archive::Archive |
( |
const std::string & |
path, |
|
|
std::shared_ptr< ResourceManager > |
resourceManager = nullptr, |
|
|
std::shared_ptr< Keystore > |
keystore = nullptr |
|
) |
| |
Constructs an Archive for the given filesystem path.
- Parameters
-
| path | Absolute or relative path to the archive file or directory. |
◆ ~Archive()
| Ship::Archive::~Archive |
( |
| ) |
|
◆ Close()
| virtual bool Ship::Archive::Close |
( |
| ) |
|
|
pure virtual |
◆ GetGameVersion()
| uint32_t Ship::Archive::GetGameVersion |
( |
| ) |
|
Returns the game version encoded in the archive manifest.
- Note
- Check HasGameVersion() first; the value is undefined if there is none.
◆ GetManifest()
Returns the parsed archive manifest.
◆ GetPath()
| const std::string & Ship::Archive::GetPath |
( |
| ) |
|
Returns the filesystem path this archive was opened from.
◆ HasFile() [1/2]
| bool Ship::Archive::HasFile |
( |
const std::string & |
filePath | ) |
|
Checks whether the archive contains a file at the given path.
- Parameters
-
| filePath | Virtual path to look up. |
- Returns
- true if the file exists in this archive.
◆ HasFile() [2/2]
| bool Ship::Archive::HasFile |
( |
uint64_t |
hash | ) |
|
Checks whether the archive contains a file with the given hash.
- Parameters
-
| hash | 64-bit hash of the file path. |
- Returns
- true if the hash is found in this archive.
◆ HasGameVersion()
| bool Ship::Archive::HasGameVersion |
( |
| ) |
|
Returns true if a game version value was found in the manifest.
◆ IndexFile()
| void Ship::Archive::IndexFile |
( |
const std::string & |
filePath | ) |
|
|
protected |
Adds a file to the internal hash→path index.
- Parameters
-
| filePath | Virtual path of the file to index. |
◆ IsChecksumValid()
| bool Ship::Archive::IsChecksumValid |
( |
| ) |
|
Returns true if the archive's checksum field matches the computed checksum.
◆ IsInitialized()
| bool Ship::Archive::IsInitialized |
( |
| ) |
|
Returns true if the archive has been successfully initialized/opened.
◆ IsSigned()
| bool Ship::Archive::IsSigned |
( |
| ) |
|
Returns true if the archive carries a digital signature in its manifest.
◆ ListFiles() [1/2]
| std::shared_ptr< std::unordered_map< uint64_t, std::string > > Ship::Archive::ListFiles |
( |
| ) |
|
Returns a map of all files indexed in this archive (hash → path).
- Returns
- Shared pointer to the complete hash→path map.
◆ ListFiles() [2/2]
| std::shared_ptr< std::unordered_map< uint64_t, std::string > > Ship::Archive::ListFiles |
( |
const std::string & |
filter | ) |
|
Returns only the files whose paths match the given filter string.
- Parameters
-
| filter | Substring or glob pattern to match against virtual paths. |
- Returns
- Shared pointer to a filtered hash→path map.
◆ Load()
| void Ship::Archive::Load |
( |
| ) |
|
Opens and indexes the archive, making its contents available for loading.
Calls Open() and then validates the manifest and signature if present.
◆ LoadFile() [1/2]
| virtual std::shared_ptr< File > Ship::Archive::LoadFile |
( |
const std::string & |
filePath | ) |
|
|
pure virtual |
◆ LoadFile() [2/2]
| virtual std::shared_ptr< File > Ship::Archive::LoadFile |
( |
uint64_t |
hash | ) |
|
|
pure virtual |
◆ Open()
| virtual bool Ship::Archive::Open |
( |
| ) |
|
|
pure virtual |
◆ operator==()
| bool Ship::Archive::operator== |
( |
const Archive & |
rhs | ) |
const |
Two archives are equal when they refer to the same underlying path.
◆ SetGameVersion()
| void Ship::Archive::SetGameVersion |
( |
uint32_t |
gameVersion | ) |
|
|
protected |
Stores the game version parsed from the manifest.
◆ SetInitialized()
| void Ship::Archive::SetInitialized |
( |
bool |
isInitialized | ) |
|
|
protected |
◆ Unload()
| void Ship::Archive::Unload |
( |
| ) |
|
Closes the archive and releases all associated resources.
Calls Close() and clears the internal hash table.
◆ Validate()
| void Ship::Archive::Validate |
( |
| ) |
|
|
protected |
Validates the manifest checksum and signature, setting mIsSigned / mIsChecksumValid.
◆ WriteFile()
| virtual bool Ship::Archive::WriteFile |
( |
const std::string & |
filename, |
|
|
const std::vector< uint8_t > & |
data |
|
) |
| |
|
pure virtual |
◆ ArchiveManager
◆ mKeystore
| std::shared_ptr<Keystore> Ship::Archive::mKeystore |
|
protected |
◆ mResourceManager
The documentation for this class was generated from the following file: