Limo
A simple mod manager
Loading...
Searching...
No Matches
lspakextractor.h
Go to the documentation of this file.
1
5
6
#pragma once
7
8
#include "
lspakfilelistentry.h
"
9
#include "
lspakheader.h
"
10
#include <filesystem>
11
#include <vector>
12
13
17
class
LsPakExtractor
18
{
19
public
:
24
LsPakExtractor
(
const
std::filesystem::path& source_path);
25
27
void
init
();
32
std::vector<std::filesystem::path>
getFileList
();
38
std::string
extractFile
(
int
file_id);
39
40
private
:
42
static
constexpr
int
COMPRESSION_MASK
= 0xf;
44
static
constexpr
int
COMPRESSION_NONE
= 0;
46
static
constexpr
int
COMPRESSION_ZLIB
= 1;
48
static
constexpr
int
COMPRESSION_LZ4
= 2;
50
static
constexpr
int
COMPRESSION_ZSTD
= 3;
52
static
constexpr
unsigned
int
LS_PAK_MAGIC_HEADER_NUMBER
= 0x4b50534c;
54
static
constexpr
unsigned
int
LS_PAK_SUPPORTED_VERSION
= 18;
56
std::filesystem::path
source_path_
;
58
std::unique_ptr<LsPakHeader>
header_
;
60
std::vector<LsPakFileListEntry>
file_list_
;
61
70
std::string
extractData
(
unsigned
long
offset
,
71
unsigned
int
length,
72
unsigned
int
uncompressed_size
,
73
int
compression_type);
78
unsigned
int
readFileList
();
79
};
LsPakExtractor::LS_PAK_SUPPORTED_VERSION
static constexpr unsigned int LS_PAK_SUPPORTED_VERSION
Currently the only supported archive format version.
Definition
lspakextractor.h:54
LsPakExtractor::LsPakExtractor
LsPakExtractor(const std::filesystem::path &source_path)
Sets the archive path to the given path.
Definition
lspakextractor.cpp:13
LsPakExtractor::init
void init()
Initializes header and file list from the source archive.
Definition
lspakextractor.cpp:15
LsPakExtractor::COMPRESSION_NONE
static constexpr int COMPRESSION_NONE
Indicates file is uncompressed.
Definition
lspakextractor.h:44
LsPakExtractor::COMPRESSION_ZLIB
static constexpr int COMPRESSION_ZLIB
Indicates file is compressed using zlib.
Definition
lspakextractor.h:46
LsPakExtractor::readFileList
unsigned int readFileList()
Reads the file list from the source archive and initializes file_list_.
Definition
lspakextractor.cpp:116
LsPakExtractor::COMPRESSION_MASK
static constexpr int COMPRESSION_MASK
Mask used to get compression type from file list entry flags.
Definition
lspakextractor.h:42
LsPakExtractor::source_path_
std::filesystem::path source_path_
Path to the source archive.
Definition
lspakextractor.h:56
LsPakExtractor::extractFile
std::string extractFile(int file_id)
Decompresses a file in the archive.
Definition
lspakextractor.cpp:109
LsPakExtractor::header_
std::unique_ptr< LsPakHeader > header_
Contains the archive's header.
Definition
lspakextractor.h:58
LsPakExtractor::COMPRESSION_ZSTD
static constexpr int COMPRESSION_ZSTD
Indicates file is compressed using zstd.
Definition
lspakextractor.h:50
LsPakExtractor::extractData
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.
Definition
lspakextractor.cpp:39
LsPakExtractor::COMPRESSION_LZ4
static constexpr int COMPRESSION_LZ4
Indicates file is compressed using lz4.
Definition
lspakextractor.h:48
LsPakExtractor::LS_PAK_MAGIC_HEADER_NUMBER
static constexpr unsigned int LS_PAK_MAGIC_HEADER_NUMBER
Indicates file is a supported .pak archive.
Definition
lspakextractor.h:52
LsPakExtractor::file_list_
std::vector< LsPakFileListEntry > file_list_
Contains all file list entries of the archive.
Definition
lspakextractor.h:60
LsPakExtractor::getFileList
std::vector< std::filesystem::path > getFileList()
Returns a vector of paths to files in the archive.
Definition
lspakextractor.cpp:101
lspakfilelistentry.h
Header for the LsPakFileListEntry class.
uncompressed_size
uint32_t uncompressed_size
Uncompressed size of the file.
Definition
lspakfilelistentry.h:11
offset
uint64_t offset
Offset of the compressed file in the archive.
Definition
lspakfilelistentry.h:3
lspakheader.h
Header for the LsPakHeader struct.
src
core
lspakextractor.h
Generated by
1.13.2