SourcePP
Several modern C++20 libraries for sanely parsing Valve's formats.
Toggle main menu visibility
Loading...
Searching...
No Matches
PAK.h
Go to the documentation of this file.
1
// ReSharper disable CppRedundantQualifier
2
3
#pragma once
4
5
#include <
sourcepp/parser/Binary.h
>
6
7
#include "
../PackFile.h
"
8
9
namespace
vpkpp
{
10
11
constexpr
uint8_t
PAK_FILENAME_MAX_SIZE
= 56;
12
constexpr
auto
PAK_SIGNATURE
=
sourcepp::parser::binary::makeFourCC
(
"PACK"
);
13
14
constexpr
uint8_t
PAK_SIN_FILENAME_MAX_SIZE
= 120;
15
constexpr
auto
PAK_SIN_SIGNATURE
=
sourcepp::parser::binary::makeFourCC
(
"SPAK"
);
16
17
constexpr
auto
PAK_SIN_RELOADED_SIGNATURE
=
sourcepp::parser::binary::makeFourCC
(
"SRPK"
);
18
19
constexpr
uint8_t
PAK_HROT_FILENAME_MAX_SIZE
= 120;
20
constexpr
auto
PAK_HROT_SIGNATURE
=
sourcepp::parser::binary::makeFourCC
(
"HROT"
);
21
22
constexpr
std::string_view
PAK_EXTENSION
=
".pak"
;
23
constexpr
std::string_view
SIN_EXTENSION
=
".sin"
;
24
25
class
PAK
:
public
PackFile
{
26
public
:
27
enum class
Type
{
28
PAK
,
29
SIN,
30
SIN_RELOADED,
31
HROT,
32
};
33
35
static
std::unique_ptr<PackFile>
create
(
const
std::string& path,
Type
type
=
Type::PAK
);
36
38
[[nodiscard]]
static
std::unique_ptr<PackFile>
open
(
const
std::string& path,
const
EntryCallback
& callback =
nullptr
);
39
40
[[nodiscard]] std::optional<std::vector<std::byte>>
readEntry
(
const
std::string& path_)
const override
;
41
42
bool
bake
(
const
std::string& outputDir_
/*= ""*/
,
BakeOptions
options
/*= {}*/
,
const
EntryCallback
& callback
/*= nullptr*/
)
override
;
43
44
[[nodiscard]]
Attribute
getSupportedEntryAttributes
()
const override
;
45
46
[[nodiscard]]
Type
getType
()
const
;
47
48
void
setType
(
Type
type_);
49
50
protected
:
51
using
PackFile::PackFile
;
52
53
void
addEntryInternal
(
Entry
& entry,
const
std::string& path, std::vector<std::byte>& buffer,
EntryOptions
options)
override
;
54
55
[[nodiscard]] uint32_t
getSignature
()
const
;
56
57
[[nodiscard]] uint8_t
getFilenameLength
()
const
;
58
59
Type
type
=
Type::PAK
;
60
61
private
:
62
VPKPP_REGISTER_PACKFILE_OPEN(
PAK_EXTENSION
, &
PAK::open
);
63
VPKPP_REGISTER_PACKFILE_OPEN(
SIN_EXTENSION
, &
PAK::open
);
64
};
65
66
}
// namespace vpkpp
Binary.h
PackFile.h
vpkpp::Entry
This class represents the metadata that a file has inside a PackFile.
Definition
Entry.h:14
vpkpp::PAK
Definition
PAK.h:25
vpkpp::PAK::create
static std::unique_ptr< PackFile > create(const std::string &path, Type type=Type::PAK)
Create a PAK file.
Definition
PAK.cpp:12
vpkpp::PAK::open
static std::unique_ptr< PackFile > open(const std::string &path, const EntryCallback &callback=nullptr)
Open a PAK file.
Definition
PAK.cpp:36
vpkpp::PAK::readEntry
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:118
vpkpp::PAK::Type
Type
Definition
PAK.h:27
vpkpp::PAK::Type::PAK
@ PAK
Definition
PAK.h:28
vpkpp::PAK::getType
Type getType() const
Definition
PAK.cpp:258
vpkpp::PAK::getSupportedEntryAttributes
Attribute getSupportedEntryAttributes() const override
Returns a list of supported entry attributes Mostly for GUI programs that show entries and their meta...
Definition
PAK.cpp:253
vpkpp::PAK::getFilenameLength
uint8_t getFilenameLength() const
Definition
PAK.cpp:280
vpkpp::PAK::getSignature
uint32_t getSignature() const
Definition
PAK.cpp:266
vpkpp::PAK::type
Type type
Definition
PAK.h:59
vpkpp::PAK::addEntryInternal
void addEntryInternal(Entry &entry, const std::string &path, std::vector< std::byte > &buffer, EntryOptions options) override
Definition
PAK.cpp:137
vpkpp::PAK::setType
void setType(Type type_)
Definition
PAK.cpp:262
vpkpp::PAK::PackFile
PackFile(const PackFile &other)=delete
vpkpp::PackFile::EntryCallback
EntryCallbackBase< void > EntryCallback
Definition
PackFile.h:40
vpkpp::PackFile::bake
bool bake()
If output folder is an empty string, it will overwrite the original.
Definition
PackFile.cpp:369
vpkpp::PackFile::PackFile
PackFile(const PackFile &other)=delete
sourcepp::parser::binary::makeFourCC
consteval uint32_t makeFourCC(const char fourCC[4])
Creates a FourCC identifier from a string of 4 characters.
Definition
Binary.h:20
vpkpp
Definition
Attribute.h:5
vpkpp::PAK_SIN_RELOADED_SIGNATURE
constexpr auto PAK_SIN_RELOADED_SIGNATURE
Definition
PAK.h:17
vpkpp::PAK_HROT_SIGNATURE
constexpr auto PAK_HROT_SIGNATURE
Definition
PAK.h:20
vpkpp::PAK_SIN_SIGNATURE
constexpr auto PAK_SIN_SIGNATURE
Definition
PAK.h:15
vpkpp::PAK_SIGNATURE
constexpr auto PAK_SIGNATURE
Definition
PAK.h:12
vpkpp::Attribute
Attribute
Definition
Attribute.h:7
vpkpp::SIN_EXTENSION
constexpr std::string_view SIN_EXTENSION
Definition
PAK.h:23
vpkpp::PAK_SIN_FILENAME_MAX_SIZE
constexpr uint8_t PAK_SIN_FILENAME_MAX_SIZE
Definition
PAK.h:14
vpkpp::PAK_HROT_FILENAME_MAX_SIZE
constexpr uint8_t PAK_HROT_FILENAME_MAX_SIZE
Definition
PAK.h:19
vpkpp::PAK_FILENAME_MAX_SIZE
constexpr uint8_t PAK_FILENAME_MAX_SIZE
Definition
PAK.h:11
vpkpp::PAK_EXTENSION
constexpr std::string_view PAK_EXTENSION
Definition
PAK.h:22
vpkpp::BakeOptions
Definition
Options.h:20
vpkpp::EntryOptions
Definition
Options.h:34
include
vpkpp
format
PAK.h
Generated on
for SourcePP by
1.18.0