Class providing functions for extracting files from a .pak archive used for Baldurs Gate 3.
More...
#include <lspakextractor.h>
|
| LsPakExtractor (const std::filesystem::path &source_path) |
| Sets the archive path to the given path.
|
|
void | init () |
| Initializes header and file list from the source archive.
|
|
std::vector< std::filesystem::path > | getFileList () |
| Returns a vector of paths to files in the archive.
|
|
std::string | extractFile (int file_id) |
| Decompresses a file in the archive.
|
|
|
std::string | extractData (unsigned long offset, unsigned int length, unsigned int uncompressed_size, int compression_type) |
| Extracts and, if necessary, decompresses data from the source archive.
|
|
unsigned int | readFileList () |
| Reads the file list from the source archive and initializes file_list_.
|
|
|
std::filesystem::path | source_path_ |
| Path to the source archive.
|
|
std::unique_ptr< LsPakHeader > | header_ |
| Contains the archive's header.
|
|
std::vector< LsPakFileListEntry > | file_list_ |
| Contains all file list entries of the archive.
|
|
|
static constexpr int | COMPRESSION_MASK = 0xf |
| Mask used to get compression type from file list entry flags.
|
|
static constexpr int | COMPRESSION_NONE = 0 |
| Indicates file is uncompressed.
|
|
static constexpr int | COMPRESSION_ZLIB = 1 |
| Indicates file is compressed using zlib.
|
|
static constexpr int | COMPRESSION_LZ4 = 2 |
| Indicates file is compressed using lz4.
|
|
static constexpr int | COMPRESSION_ZSTD = 3 |
| Indicates file is compressed using zstd.
|
|
static constexpr unsigned int | LS_PAK_MAGIC_HEADER_NUMBER = 0x4b50534c |
| Indicates file is a supported .pak archive.
|
|
static constexpr unsigned int | LS_PAK_SUPPORTED_VERSION = 18 |
| Currently the only supported archive format version.
|
|
Class providing functions for extracting files from a .pak archive used for Baldurs Gate 3.
◆ LsPakExtractor()
LsPakExtractor::LsPakExtractor |
( |
const std::filesystem::path & | source_path | ) |
|
Sets the archive path to the given path.
- Parameters
-
source_path | Target archive path. |
◆ extractData()
std::string LsPakExtractor::extractData |
( |
unsigned long | offset, |
|
|
unsigned int | length, |
|
|
unsigned int | uncompressed_size, |
|
|
int | compression_type ) |
|
private |
Extracts and, if necessary, decompresses data from the source archive.
- Parameters
-
offset | Offset from which to extract data. |
length | Number of bytes to read. |
uncompressed_size | Uncompressed size of the data. |
compression_type | Compression type used. |
- Returns
- The uncompressed data as a string.
◆ extractFile()
std::string LsPakExtractor::extractFile |
( |
int | file_id | ) |
|
Decompresses a file in the archive.
- Parameters
-
file_id | Index of the file to the extracted. |
- Returns
- The uncompressed file as a string.
◆ getFileList()
std::vector< std::filesystem::path > LsPakExtractor::getFileList |
( |
| ) |
|
Returns a vector of paths to files in the archive.
- Returns
- The vector.
◆ readFileList()
unsigned int LsPakExtractor::readFileList |
( |
| ) |
|
|
private |
Reads the file list from the source archive and initializes file_list_.
- Returns
- The compressed size of the file list.
The documentation for this class was generated from the following files: