SourcePP
Several modern C++20 libraries for sanely parsing Valve's formats.
Loading...
Searching...
No Matches
PAK.h
Go to the documentation of this file.
1#pragma once
2
4
5#include "../PackFile.h"
6
7namespace vpkpp {
8
9constexpr int8_t PAK_FILENAME_MAX_SIZE = 56;
11
12constexpr int8_t PAK_HROT_FILENAME_MAX_SIZE = 120;
14
15constexpr std::string_view PAK_EXTENSION = ".pak";
16
17class PAK : public PackFile {
18public:
20 static std::unique_ptr<PackFile> create(const std::string& path, bool forHROT = false);
21
23 [[nodiscard]] static std::unique_ptr<PackFile> open(const std::string& path, const EntryCallback& callback = nullptr);
24
25 static constexpr inline std::string_view GUID = "C282210FE64D46D1AE364D7E8E925542";
26
27 [[nodiscard]] constexpr std::string_view getGUID() const override {
28 return PAK::GUID;
29 }
30
31 [[nodiscard]] std::optional<std::vector<std::byte>> readEntry(const std::string& path_) const override;
32
33 bool bake(const std::string& outputDir_ /*= ""*/, BakeOptions options /*= {}*/, const EntryCallback& callback /*= nullptr*/) override;
34
35 [[nodiscard]] Attribute getSupportedEntryAttributes() const override;
36
37 [[nodiscard]] bool isHROT() const;
38
39 void setHROT(bool hrot);
40
41protected:
43
44 void addEntryInternal(Entry& entry, const std::string& path, std::vector<std::byte>& buffer, EntryOptions options) override;
45
46 bool isHROT_ = false;
47
48private:
50};
51
52} // 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
Definition: PAK.h:17
static std::unique_ptr< PackFile > open(const std::string &path, const EntryCallback &callback=nullptr)
Open a PAK file.
Definition: PAK.cpp:21
static std::unique_ptr< PackFile > create(const std::string &path, bool forHROT=false)
Create a PAK file.
Definition: PAK.cpp:10
constexpr std::string_view getGUID() const override
Get the GUID corresponding to the pack file type.
Definition: PAK.h:27
std::optional< std::vector< std::byte > > readEntry(const std::string &path_) const override
Try to read the entry's data to a bytebuffer.
Definition: PAK.cpp:65
bool isHROT() const
Definition: PAK.cpp:154
void setHROT(bool hrot)
Definition: PAK.cpp:158
Attribute getSupportedEntryAttributes() const override
Returns a list of supported entry attributes Mostly for GUI programs that show entries and their meta...
Definition: PAK.cpp:149
void addEntryInternal(Entry &entry, const std::string &path, std::vector< std::byte > &buffer, EntryOptions options) override
Definition: PAK.cpp:84
bool isHROT_
Definition: PAK.h:46
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: PAK.cpp:91
static constexpr std::string_view GUID
Definition: PAK.h:25
EntryCallbackBase< void > EntryCallback
Definition: PackFile.h:30
PackFile(const PackFile &other)=delete
consteval uint32_t makeFourCC(const char fourCC[4])
Creates a FourCC identifier from a string of 4 characters.
Definition: Binary.h:18
Definition: Attribute.h:5
constexpr auto PAK_HROT_SIGNATURE
Definition: PAK.h:13
constexpr int8_t PAK_FILENAME_MAX_SIZE
Definition: PAK.h:9
constexpr auto PAK_SIGNATURE
Definition: PAK.h:10
Attribute
Definition: Attribute.h:7
constexpr int8_t PAK_HROT_FILENAME_MAX_SIZE
Definition: PAK.h:12
constexpr std::string_view PAK_EXTENSION
Definition: PAK.h:15