SourcePP
Several modern C++20 libraries for sanely parsing Valve's formats.
Loading...
Searching...
No Matches
GMA.h
Go to the documentation of this file.
1// ReSharper disable CppRedundantQualifier
2
3#pragma once
4
6
7#include "../PackFile.h"
8
9namespace vpkpp {
10
12constexpr std::string_view GMA_EXTENSION = ".gma";
13
14class GMA : public PackFile {
15protected:
16 struct Header {
17 int32_t signature;
18 uint8_t version;
19 uint64_t steamID;
20 uint64_t timestamp;
21 std::string requiredContent;
22 std::string addonName;
23 std::string addonDescription;
24 std::string addonAuthor;
25 int32_t addonVersion;
26 };
27
28public:
30 [[nodiscard]] static std::unique_ptr<PackFile> open(const std::string& path, const EntryCallback& callback = nullptr);
31
32 static constexpr std::string_view GUID = "49191CA83B7B4EBBA86D0EA364AAC457";
33
34 [[nodiscard]] constexpr std::string_view getGUID() const override {
35 return GMA::GUID;
36 }
37
38 [[nodiscard]] constexpr bool hasEntryChecksums() const override {
39 return true;
40 }
41
42 [[nodiscard]] std::vector<std::string> verifyEntryChecksums() const override;
43
44 [[nodiscard]] bool hasPackFileChecksum() const override;
45
46 [[nodiscard]] bool verifyPackFileChecksum() const override;
47
48 [[nodiscard]] std::optional<std::vector<std::byte>> readEntry(const std::string& path_) const override;
49
50 bool bake(const std::string& outputDir_ /*= ""*/, BakeOptions options /*= {}*/, const EntryCallback& callback /*= nullptr*/) override;
51
52 [[nodiscard]] Attribute getSupportedEntryAttributes() const override;
53
54 [[nodiscard]] explicit operator std::string() const override;
55
56protected:
58
59 void addEntryInternal(Entry& entry, const std::string& path, std::vector<std::byte>& buffer, EntryOptions options) override;
60
62
63private:
65};
66
67} // 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
void addEntryInternal(Entry &entry, const std::string &path, std::vector< std::byte > &buffer, EntryOptions options) override
Definition GMA.cpp:107
Header header
Definition GMA.h:61
bool verifyPackFileChecksum() const override
Verify the checksum of the entire file, returns true on success Will return true if there is no check...
Definition GMA.cpp:74
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 GMA.cpp:115
Attribute getSupportedEntryAttributes() const override
Returns a list of supported entry attributes Mostly for GUI programs that show entries and their meta...
Definition GMA.cpp:195
static std::unique_ptr< PackFile > open(const std::string &path, const EntryCallback &callback=nullptr)
Open a GMA file.
Definition GMA.cpp:12
constexpr bool hasEntryChecksums() const override
Returns true if the format has a checksum for each entry.
Definition GMA.h:38
std::vector< std::string > verifyEntryChecksums() const override
Verify the checksums of each file, if a file fails the check its path will be added to the vector If ...
Definition GMA.cpp:66
bool hasPackFileChecksum() const override
Returns true if the entire file has a checksum.
Definition GMA.cpp:70
constexpr std::string_view getGUID() const override
Get the GUID corresponding to the pack file type.
Definition GMA.h:34
std::optional< std::vector< std::byte > > readEntry(const std::string &path_) const override
Try to read the entry's data to a bytebuffer.
Definition GMA.cpp:88
PackFile(const PackFile &other)=delete
static constexpr std::string_view GUID
Definition GMA.h:32
EntryCallbackBase< void > EntryCallback
Definition PackFile.h:38
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:20
constexpr std::string_view GMA_EXTENSION
Definition GMA.h:12
Attribute
Definition Attribute.h:7
constexpr auto GMA_SIGNATURE
Definition GMA.h:11
std::string requiredContent
Definition GMA.h:21
uint64_t timestamp
Definition GMA.h:20
std::string addonDescription
Definition GMA.h:23
int32_t addonVersion
Definition GMA.h:25
uint64_t steamID
Definition GMA.h:19
uint8_t version
Definition GMA.h:18
std::string addonAuthor
Definition GMA.h:24
int32_t signature
Definition GMA.h:17
std::string addonName
Definition GMA.h:22