SourcePP
Several modern C++20 libraries for sanely parsing Valve's formats.
Loading...
Searching...
No Matches
VPK_VTMB.h
Go to the documentation of this file.
1// ReSharper disable CppRedundantQualifier
2
3#pragma once
4
5#include "../PackFile.h"
6
7namespace vpkpp {
8
9constexpr std::string_view VPK_VTMB_EXTENSION = ".vpk";
10
11class VPK_VTMB : public PackFile {
12public:
14 static std::unique_ptr<PackFile> create(const std::string& path);
15
17 [[nodiscard]] static std::unique_ptr<PackFile> open(const std::string& path, const EntryCallback& callback = nullptr);
18
19 static constexpr std::string_view GUID = "5942653FBD0F4A2D9EF33CDDA668C396";
20
21 [[nodiscard]] constexpr std::string_view getGUID() const override {
22 return VPK_VTMB::GUID;
23 }
24
25 [[nodiscard]] std::optional<std::vector<std::byte>> readEntry(const std::string& path_) const override;
26
27 bool bake(const std::string& outputDir_ /*= ""*/, BakeOptions options /*= {}*/, const EntryCallback& callback /*= nullptr*/) override;
28
29 [[nodiscard]] std::string getTruncatedFilestem() const override;
30
31 [[nodiscard]] Attribute getSupportedEntryAttributes() const override;
32
33protected:
35
36 void openNumbered(uint32_t archiveIndex, const std::string& path, const EntryCallback& callback);
37
38 void addEntryInternal(Entry& entry, const std::string& path, std::vector<std::byte>& buffer, EntryOptions options) override;
39
40 std::vector<uint32_t> knownArchives;
41 uint32_t currentArchive = 0;
42
43private:
45};
46
47} // namespace vpkpp
#define VPKPP_REGISTER_PACKFILE_OPEN(extension, function)
Definition PackFile.h:255
This class represents the metadata that a file has inside a PackFile.
Definition Entry.h:14
EntryCallbackBase< void > EntryCallback
Definition PackFile.h:38
PackFile(const PackFile &other)=delete
static std::unique_ptr< PackFile > open(const std::string &path, const EntryCallback &callback=nullptr)
Open Vampire: The Masquerade - Bloodlines VPK files.
Definition VPK_VTMB.cpp:23
static std::unique_ptr< PackFile > create(const std::string &path)
Create Vampire: The Masquerade - Bloodlines VPK files.
Definition VPK_VTMB.cpp:12
static constexpr std::string_view GUID
Definition VPK_VTMB.h:19
Attribute getSupportedEntryAttributes() const override
Returns a list of supported entry attributes Mostly for GUI programs that show entries and their meta...
Definition VPK_VTMB.cpp:204
std::vector< uint32_t > knownArchives
Definition VPK_VTMB.h:40
std::optional< std::vector< std::byte > > readEntry(const std::string &path_) const override
Try to read the entry's data to a bytebuffer.
Definition VPK_VTMB.cpp:92
bool bake(const std::string &outputDir_, BakeOptions options, const EntryCallback &callback) override
If output folder is an empty string, it will overwrite the original.
Definition VPK_VTMB.cpp:119
void addEntryInternal(Entry &entry, const std::string &path, std::vector< std::byte > &buffer, EntryOptions options) override
Definition VPK_VTMB.cpp:111
std::string getTruncatedFilestem() const override
/home/user/pak01_dir.vpk -> pak01
Definition VPK_VTMB.cpp:198
PackFile(const PackFile &other)=delete
void openNumbered(uint32_t archiveIndex, const std::string &path, const EntryCallback &callback)
Definition VPK_VTMB.cpp:55
uint32_t currentArchive
Definition VPK_VTMB.h:41
constexpr std::string_view getGUID() const override
Get the GUID corresponding to the pack file type.
Definition VPK_VTMB.h:21
constexpr std::string_view VPK_VTMB_EXTENSION
Definition VPK_VTMB.h:9
Attribute
Definition Attribute.h:7