PackFile is a class with two purposes. First, it implements IFileLoader, allowing to be used as a simple file system. Second, it has the Pack and Unpack methods, used to create .pak files, used by this file system. Creating .pak files has several benefits. The first one is obfuscation, making it more difficult to end users to get access to your game assets. The second one is being loaded as a stream, as it allows to only load what is needed at the moment. It also is easily extended to, for example, zip all or only specific files, reducing final build size. Ownership:
More...
#include <PackFile.h>
|
|
| PackFile (const std::string &packfilePath) |
| virtual bool | IsValid () const |
| | Tells us if the file loader can be used at the moment.
|
|
size_t | Unpack (const std::string &outFolder) |
| virtual std::vector< char > | GetFile (const std::string &outFolder) |
| | Give us a binary representation of a file in a filesystem.
|
| virtual bool | HasFile (const std::string &outFolder) const |
| | Tells us if the filesystem has a file.
|
| virtual std::vector< std::string > | GetAvailableFiles () const |
| | Tells us which files are in the filesystem.
|
|
|
static size_t | Pack (const std::string &folderPath, const std::string &outPath) |
PackFile is a class with two purposes. First, it implements IFileLoader, allowing to be used as a simple file system. Second, it has the Pack and Unpack methods, used to create .pak files, used by this file system. Creating .pak files has several benefits. The first one is obfuscation, making it more difficult to end users to get access to your game assets. The second one is being loaded as a stream, as it allows to only load what is needed at the moment. It also is easily extended to, for example, zip all or only specific files, reducing final build size. Ownership:
- It takes ownership of the point in memory where the pak file is. However, it is created as a stream and not loaded fully on initialization. Guarantees:
- If the file exist at the specified path and is a valid pak file, the metadata will be loaded and the pack open. Thread safe:
- GetFile is not thread safe, as it uses a single handler to seek and read data. Check IFileLoader.h for more info on the interface methods.
◆ GetAvailableFiles()
| std::vector< std::string > Mochi::FS::PackFile::GetAvailableFiles |
( |
| ) |
const |
|
virtual |
Tells us which files are in the filesystem.
- Returns
- A vector with the unique identifiers of all files
Implements Mochi::FS::IFileLoader.
◆ GetFile()
| std::vector< char > Mochi::FS::PackFile::GetFile |
( |
const std::string & | path | ) |
|
|
virtual |
Give us a binary representation of a file in a filesystem.
- Exceptions
-
- Parameters
-
| path | A path, or unique identifier to the file |
- Returns
- A vector of chars, or binary representation of a file.
Implements Mochi::FS::IFileLoader.
◆ HasFile()
| bool Mochi::FS::PackFile::HasFile |
( |
const std::string & | path | ) |
const |
|
virtual |
Tells us if the filesystem has a file.
- Parameters
-
| path | A path, or unique identifier to the file |
- Returns
- True if it has the file, false if not
Implements Mochi::FS::IFileLoader.
◆ IsValid()
| bool Mochi::FS::PackFile::IsValid |
( |
| ) |
const |
|
virtual |
Tells us if the file loader can be used at the moment.
- Returns
- True if can be used, false if not
Implements Mochi::FS::IFileLoader.
The documentation for this class was generated from the following files:
- Engine/src/Packer/PackFile.h
- Engine/src/Packer/PackFile.cpp