SourcePP
Several modern C++20 libraries for sanely parsing Valve's formats.
Loading...
Searching...
No Matches
TAB.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
11constexpr std::string_view TAB_EXTENSION = ".tab";
12
13constexpr auto TAB_FILENAME_MAX_SIZE = 128;
14constexpr std::string_view TAB_HASHED_FILEPATH_PREFIX = "__hashed__/";
15
16constexpr std::string_view ARC_EXTENSION = ".arc";
17
19constexpr uint32_t ARC_CHUNK_SIZE = 1024 * 1024 * 1024;
20
21class TAB : public PackFile {
22public:
23 enum class Version {
26 };
27
29 static std::unique_ptr<PackFile> create(const std::string& path, Version version = Version::JC1_LE, uint32_t sectorSize = 2048);
30
32 [[nodiscard]] static std::unique_ptr<PackFile> open(const std::string& path, const EntryCallback& callback = nullptr);
33
34 [[nodiscard]] std::optional<std::vector<std::byte>> readEntry(const std::string& path_) const override;
35
36 bool bake(const std::string& outputDir_ /*= ""*/, BakeOptions options /*= {}*/, const EntryCallback& callback /*= nullptr*/) override;
37
38 [[nodiscard]] Attribute getSupportedEntryAttributes() const override;
39
40 [[nodiscard]] explicit operator std::string() const override;
41
42 [[nodiscard]] Version getVersion() const;
43
44 void setVersion(Version version_);
45
46 [[nodiscard]] uint32_t getSectorSize() const;
47
48 void setSectorSize(uint32_t sectorSize_);
49
50 [[nodiscard]] static uint32_t hashFilePath(const std::string& filepath);
51
52protected:
54
55 void addEntryInternal(Entry& entry, const std::string& path, std::vector<std::byte>& buffer, EntryOptions options) override;
56
58 uint32_t sectorSize = 0;
59 uint32_t numArchives = 0;
60
61private:
63};
64
65} // namespace vpkpp
#define VPKPP_REGISTER_PACKFILE_OPEN(extension, function)
Definition PackFile.h:254
This class represents the metadata that a file has inside a PackFile.
Definition Entry.h:14
EntryCallbackBase< void > EntryCallback
Definition PackFile.h:38
bool bake()
If output folder is an empty string, it will overwrite the original.
Definition PackFile.cpp:369
PackFile(const PackFile &other)=delete
static std::unique_ptr< PackFile > open(const std::string &path, const EntryCallback &callback=nullptr)
Open a TAB file.
Definition TAB.cpp:39
void setVersion(Version version_)
Definition TAB.cpp:288
uint32_t getSectorSize() const
Definition TAB.cpp:292
uint32_t numArchives
Definition TAB.h:59
uint32_t sectorSize
Definition TAB.h:58
void addEntryInternal(Entry &entry, const std::string &path, std::vector< std::byte > &buffer, EntryOptions options) override
Definition TAB.cpp:149
void setSectorSize(uint32_t sectorSize_)
Definition TAB.cpp:296
Attribute getSupportedEntryAttributes() const override
Returns a list of supported entry attributes Mostly for GUI programs that show entries and their meta...
Definition TAB.cpp:275
std::optional< std::vector< std::byte > > readEntry(const std::string &path_) const override
Try to read the entry's data to a bytebuffer.
Definition TAB.cpp:130
static uint32_t hashFilePath(const std::string &filepath)
Definition TAB.cpp:300
Version version
Definition TAB.h:57
PackFile(const PackFile &other)=delete
Version
Definition TAB.h:23
Version getVersion() const
Definition TAB.cpp:284
static std::unique_ptr< PackFile > create(const std::string &path, Version version=Version::JC1_LE, uint32_t sectorSize=2048)
Create a TAB file.
Definition TAB.cpp:27
constexpr std::string_view ARC_EXTENSION
Definition TAB.h:16
constexpr uint32_t ARC_CHUNK_SIZE
Chunk size in bytes (1gb).
Definition TAB.h:19
constexpr auto TAB_FILENAME_MAX_SIZE
Definition TAB.h:13
Attribute
Definition Attribute.h:7
constexpr std::string_view TAB_EXTENSION
Definition TAB.h:11
constexpr std::string_view TAB_HASHED_FILEPATH_PREFIX
Definition TAB.h:14