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#pragma once
2
3#include "../PackFile.h"
4
5namespace vpkpp {
6
7constexpr std::string_view VPK_VTMB_EXTENSION = ".vpk";
8
9class VPK_VTMB : public PackFile {
10public:
12 static std::unique_ptr<PackFile> create(const std::string& path);
13
15 [[nodiscard]] static std::unique_ptr<PackFile> open(const std::string& path, const EntryCallback& callback = nullptr);
16
17 static constexpr inline std::string_view GUID = "5942653FBD0F4A2D9EF33CDDA668C396";
18
19 [[nodiscard]] constexpr std::string_view getGUID() const override {
20 return VPK_VTMB::GUID;
21 }
22
23 [[nodiscard]] std::optional<std::vector<std::byte>> readEntry(const std::string& path_) const override;
24
25 bool bake(const std::string& outputDir_ /*= ""*/, BakeOptions options /*= {}*/, const EntryCallback& callback /*= nullptr*/) override;
26
27 [[nodiscard]] std::string getTruncatedFilestem() const override;
28
29 [[nodiscard]] Attribute getSupportedEntryAttributes() const override;
30
31protected:
33
34 void openNumbered(uint32_t archiveIndex, const std::string& path, const EntryCallback& callback);
35
36 void addEntryInternal(Entry& entry, const std::string& path, std::vector<std::byte>& buffer, EntryOptions options) override;
37
38 std::vector<uint32_t> knownArchives;
39 uint32_t currentArchive = 0;
40
41private:
43};
44
45} // namespace vpkpp
#define VPKPP_REGISTER_PACKFILE_OPEN(extension, function)
Definition: PackFile.h:242
This class represents the metadata that a file has inside a PackFile.
Definition: Entry.h:14
EntryCallbackBase< void > EntryCallback
Definition: PackFile.h:30
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:17
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:38
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
void openNumbered(uint32_t archiveIndex, const std::string &path, const EntryCallback &callback)
Definition: VPK_VTMB.cpp:55
uint32_t currentArchive
Definition: VPK_VTMB.h:39
constexpr std::string_view getGUID() const override
Get the GUID corresponding to the pack file type.
Definition: VPK_VTMB.h:19
Definition: Attribute.h:5
constexpr std::string_view VPK_VTMB_EXTENSION
Definition: VPK_VTMB.h:7
Attribute
Definition: Attribute.h:7