SourcePP
Several modern C++20 libraries for sanely parsing Valve's formats.
Loading...
Searching...
No Matches
FGP.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 FGP_EXTENSION = ".grp";
13
14constexpr std::string_view FGP_HASHED_FILEPATH_PREFIX = "__hashed__/";
16
17class FGP : public PackFile {
18public:
20 static std::unique_ptr<PackFile> create(const std::string& path);
21
23 [[nodiscard]] static std::unique_ptr<PackFile> open(const std::string& path, const EntryCallback& callback = nullptr);
24
25 static constexpr std::string_view GUID = "BF4352054D444027AD27A8DF69178A82";
26
27 [[nodiscard]] constexpr std::string_view getGUID() const override {
28 return FGP::GUID;
29 }
30
31 [[nodiscard]] std::optional<std::vector<std::byte>> readEntry(const std::string& path_) const override;
32
33 bool renameEntry(const std::string& oldPath, const std::string& newPath) override;
34
35 bool renameDirectory(const std::string& oldDir, const std::string& newDir) override;
36
37 bool removeEntry(const std::string& path) override;
38
39 std::size_t removeDirectory(const std::string& dirName) override;
40
41 bool bake(const std::string& outputDir_ /*= ""*/, BakeOptions options /*= {}*/, const EntryCallback& callback /*= nullptr*/) override;
42
43 [[nodiscard]] Attribute getSupportedEntryAttributes() const override;
44
45 [[nodiscard]] explicit operator std::string() const override;
46
47 [[nodiscard]] std::string getLoadingScreenFilePath() const;
48
49 void setLoadingScreenFilePath(const std::string& path);
50
51 [[nodiscard]] static uint32_t hashFilePath(const std::string& filepath);
52
53protected:
55
56 void addEntryInternal(Entry& entry, const std::string& path, std::vector<std::byte>& buffer, EntryOptions options) override;
57
58 static uint32_t getHeaderSize(uint32_t version, uint32_t fileCount);
59
60 uint32_t version = 0;
61 std::string loadingScreenPath;
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 FGP.cpp:184
void setLoadingScreenFilePath(const std::string &path)
Definition FGP.cpp:339
static std::unique_ptr< PackFile > create(const std::string &path)
Create an FGP file.
Definition FGP.cpp:22
std::string loadingScreenPath
Definition FGP.h:61
bool renameEntry(const std::string &oldPath, const std::string &newPath) override
Rename an existing entry.
Definition FGP.cpp:144
std::optional< std::vector< std::byte > > readEntry(const std::string &path_) const override
Try to read the entry's data to a bytebuffer.
Definition FGP.cpp:117
uint32_t version
Definition FGP.h:60
bool renameDirectory(const std::string &oldDir, const std::string &newDir) override
Rename an existing directory.
Definition FGP.cpp:154
std::size_t removeDirectory(const std::string &dirName) override
Remove a directory.
Definition FGP.cpp:174
static constexpr std::string_view GUID
Definition FGP.h:25
std::string getLoadingScreenFilePath() const
Definition FGP.cpp:335
static uint32_t hashFilePath(const std::string &filepath)
Definition FGP.cpp:345
Attribute getSupportedEntryAttributes() const override
Returns a list of supported entry attributes Mostly for GUI programs that show entries and their meta...
Definition FGP.cpp:325
constexpr std::string_view getGUID() const override
Get the GUID corresponding to the pack file type.
Definition FGP.h:27
PackFile(const PackFile &other)=delete
bool removeEntry(const std::string &path) override
Remove an entry.
Definition FGP.cpp:164
static std::unique_ptr< PackFile > open(const std::string &path, const EntryCallback &callback=nullptr)
Open an FGP file.
Definition FGP.cpp:35
static uint32_t getHeaderSize(uint32_t version, uint32_t fileCount)
Definition FGP.cpp:349
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 FGP.cpp:194
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
consteval uint64_t makeEightCC(const char eightCC[8])
Creates a EightCC identifier from a string of 8 characters.
Definition Binary.h:29
constexpr std::string_view FGP_HASHED_FILEPATH_PREFIX
Definition FGP.h:14
constexpr std::string_view FGP_EXTENSION
Definition FGP.h:12
Attribute
Definition Attribute.h:7
constexpr auto FGP_SOURCEPP_FILENAMES_SIGNATURE
Definition FGP.h:15
constexpr auto FGP_SIGNATURE
Definition FGP.h:11