Limo
A simple mod manager
Loading...
Searching...
No Matches
LsPakExtractor Class Reference

Class providing functions for extracting files from a .pak archive used for Baldurs Gate 3. More...

#include <lspakextractor.h>

Public Member Functions

 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.
 

Private Member Functions

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_.
 

Private Attributes

std::filesystem::path source_path_
 Path to the source archive.
 
std::unique_ptr< LsPakHeaderheader_
 Contains the archive's header.
 
std::vector< LsPakFileListEntryfile_list_
 Contains all file list entries of the archive.
 

Static Private Attributes

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.
 

Detailed Description

Class providing functions for extracting files from a .pak archive used for Baldurs Gate 3.

Constructor & Destructor Documentation

◆ LsPakExtractor()

LsPakExtractor::LsPakExtractor ( const std::filesystem::path & source_path)

Sets the archive path to the given path.

Parameters
source_pathTarget archive path.

Member Function Documentation

◆ 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
offsetOffset from which to extract data.
lengthNumber of bytes to read.
uncompressed_sizeUncompressed size of the data.
compression_typeCompression 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_idIndex 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: