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