|
libultraship
Reimplementations of libultra (N64 SDK) functions for modern hardware
|
Abstract base class representing a mounted archive (OTR, O2R, or folder). More...
#include <Archive.h>
Public Member Functions | |
| 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. | |
| int32_t | GetPriority () |
| Load-order priority assigned by the ArchiveManager when the archive is mounted. Higher means loaded later. -1 if unset. | |
| void | SetPriority (int32_t priority) |
| Sets the load-order priority. Called by the ArchiveManager. | |
| 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. | |
Protected Member Functions | |
| 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. | |
Protected Attributes | |
| std::shared_ptr< ResourceManager > | mResourceManager |
| std::shared_ptr< Keystore > | mKeystore |
Friends | |
| class | ArchiveManager |
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.
| 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.
| path | Absolute or relative path to the archive file or directory. |
| Ship::Archive::~Archive | ( | ) |
|
pure virtual |
Closes the underlying archive file or directory.
Implemented in Ship::FolderArchive, Ship::O2rArchive, and Ship::OtrArchive.
| uint32_t Ship::Archive::GetGameVersion | ( | ) |
Returns the game version encoded in the archive manifest.
| const ArchiveManifest & Ship::Archive::GetManifest | ( | ) |
Returns the parsed archive manifest.
| const std::string & Ship::Archive::GetPath | ( | ) |
Returns the filesystem path this archive was opened from.
| int32_t Ship::Archive::GetPriority | ( | ) |
Load-order priority assigned by the ArchiveManager when the archive is mounted. Higher means loaded later. -1 if unset.
| bool Ship::Archive::HasFile | ( | const std::string & | filePath | ) |
Checks whether the archive contains a file at the given path.
| filePath | Virtual path to look up. |
| bool Ship::Archive::HasFile | ( | uint64_t | hash | ) |
Checks whether the archive contains a file with the given hash.
| hash | 64-bit hash of the file path. |
| bool Ship::Archive::HasGameVersion | ( | ) |
Returns true if a game version value was found in the manifest.
|
protected |
Adds a file to the internal hash→path index.
| filePath | Virtual path of the file to index. |
| bool Ship::Archive::IsChecksumValid | ( | ) |
Returns true if the archive's checksum field matches the computed checksum.
| bool Ship::Archive::IsInitialized | ( | ) |
Returns true if the archive has been successfully initialized/opened.
| bool Ship::Archive::IsSigned | ( | ) |
Returns true if the archive carries a digital signature in its manifest.
| 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).
| 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.
| filter | Substring or glob pattern to match against virtual paths. |
| 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.
|
pure virtual |
Loads a file by its virtual path.
| filePath | Virtual path within the archive (e.g. "textures/foo.tex"). |
Implemented in Ship::FolderArchive, Ship::O2rArchive, and Ship::OtrArchive.
|
pure virtual |
Loads a file by its 64-bit content hash.
| hash | CRC/hash of the file path. |
Implemented in Ship::FolderArchive, Ship::O2rArchive, and Ship::OtrArchive.
|
pure virtual |
Opens the underlying archive file or directory for reading.
Implemented in Ship::FolderArchive, Ship::O2rArchive, and Ship::OtrArchive.
| bool Ship::Archive::operator== | ( | const Archive & | rhs | ) | const |
Two archives are equal when they refer to the same underlying path.
|
protected |
Stores the game version parsed from the manifest.
|
protected |
| void Ship::Archive::SetPriority | ( | int32_t | priority | ) |
Sets the load-order priority. Called by the ArchiveManager.
| void Ship::Archive::Unload | ( | ) |
Closes the archive and releases all associated resources.
Calls Close() and clears the internal hash table.
|
protected |
Validates the manifest checksum and signature, setting mIsSigned / mIsChecksumValid.
|
pure virtual |
Writes raw data into the archive at the given path.
| filename | Target virtual path within the archive. |
| data | Raw bytes to write. |
Implemented in Ship::FolderArchive, Ship::O2rArchive, and Ship::OtrArchive.
|
friend |
|
protected |
|
protected |