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#pragma once
2
4
5#include "../PackFile.h"
6
7namespace vpkpp {
8
10constexpr std::string_view GMA_EXTENSION = ".gma";
11
12class GMA : public PackFile {
13protected:
14 struct Header {
15 int32_t signature;
16 uint8_t version;
17 uint64_t steamID;
18 uint64_t timestamp;
19 std::string requiredContent;
20 std::string addonName;
21 std::string addonDescription;
22 std::string addonAuthor;
23 int32_t addonVersion;
24 };
25
26public:
28 [[nodiscard]] static std::unique_ptr<PackFile> open(const std::string& path, const EntryCallback& callback = nullptr);
29
30 static constexpr inline std::string_view GUID = "49191CA83B7B4EBBA86D0EA364AAC457";
31
32 [[nodiscard]] constexpr std::string_view getGUID() const override {
33 return GMA::GUID;
34 }
35
36 [[nodiscard]] constexpr bool hasEntryChecksums() const override {
37 return true;
38 }
39
40 [[nodiscard]] std::vector<std::string> verifyEntryChecksums() const override;
41
42 [[nodiscard]] bool hasPackFileChecksum() const override;
43
44 [[nodiscard]] bool verifyPackFileChecksum() const override;
45
46 [[nodiscard]] std::optional<std::vector<std::byte>> readEntry(const std::string& path_) const override;
47
48 bool bake(const std::string& outputDir_ /*= ""*/, BakeOptions options /*= {}*/, const EntryCallback& callback /*= nullptr*/) override;
49
50 [[nodiscard]] Attribute getSupportedEntryAttributes() const override;
51
52 [[nodiscard]] explicit operator std::string() const override;
53
54protected:
56
57 void addEntryInternal(Entry& entry, const std::string& path, std::vector<std::byte>& buffer, EntryOptions options) override;
58
60
61private:
63};
64
65} // 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: GMA.h:12
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:59
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:36
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:32
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
static constexpr std::string_view GUID
Definition: GMA.h:30
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 std::string_view GMA_EXTENSION
Definition: GMA.h:10
Attribute
Definition: Attribute.h:7
constexpr auto GMA_SIGNATURE
Definition: GMA.h:9
std::string requiredContent
Definition: GMA.h:19
uint64_t timestamp
Definition: GMA.h:18
std::string addonDescription
Definition: GMA.h:21
int32_t addonVersion
Definition: GMA.h:23
uint64_t steamID
Definition: GMA.h:17
uint8_t version
Definition: GMA.h:16
std::string addonAuthor
Definition: GMA.h:22
int32_t signature
Definition: GMA.h:15
std::string addonName
Definition: GMA.h:20