SourcePP
Several modern C++20 libraries for sanely parsing Valve's formats.
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
uint8_t
PAK_HROT_FILENAME_MAX_SIZE
= 120;
18
constexpr
auto
PAK_HROT_SIGNATURE
=
sourcepp::parser::binary::makeFourCC
(
"HROT"
);
19
20
constexpr
std::string_view
PAK_EXTENSION
=
".pak"
;
21
constexpr
std::string_view
SIN_EXTENSION
=
".sin"
;
22
23
class
PAK
:
public
PackFile
{
24
public
:
25
enum class
Type
{
26
PAK
,
27
SIN
,
28
HROT
,
29
};
30
32
static
std::unique_ptr<PackFile>
create
(
const
std::string& path,
Type
type
=
Type::PAK
);
33
35
[[nodiscard]]
static
std::unique_ptr<PackFile>
open
(
const
std::string& path,
const
EntryCallback
& callback =
nullptr
);
36
37
[[nodiscard]] std::optional<std::vector<std::byte>>
readEntry
(
const
std::string& path_)
const override
;
38
39
bool
bake
(
const
std::string& outputDir_
/*= ""*/
,
BakeOptions
options
/*= {}*/
,
const
EntryCallback
& callback
/*= nullptr*/
)
override
;
40
41
[[nodiscard]]
Attribute
getSupportedEntryAttributes
()
const override
;
42
43
[[nodiscard]]
Type
getType
()
const
;
44
45
void
setType
(
Type
type_);
46
47
protected
:
48
using
PackFile::PackFile
;
49
50
void
addEntryInternal
(
Entry
& entry,
const
std::string& path, std::vector<std::byte>& buffer,
EntryOptions
options)
override
;
51
52
[[nodiscard]] uint32_t
getSignature
()
const
;
53
54
[[nodiscard]] uint8_t
getFilenameLength
()
const
;
55
56
Type
type
=
Type::PAK
;
57
58
private
:
59
VPKPP_REGISTER_PACKFILE_OPEN
(
PAK_EXTENSION
, &
PAK::open
);
60
VPKPP_REGISTER_PACKFILE_OPEN
(
SIN_EXTENSION
, &
PAK::open
);
61
};
62
63
}
// namespace vpkpp
Binary.h
PackFile.h
VPKPP_REGISTER_PACKFILE_OPEN
#define VPKPP_REGISTER_PACKFILE_OPEN(extension, function)
Definition
PackFile.h:254
vpkpp::Entry
This class represents the metadata that a file has inside a PackFile.
Definition
Entry.h:14
vpkpp::PAK
Definition
PAK.h:23
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:33
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:79
vpkpp::PAK::Type
Type
Definition
PAK.h:25
vpkpp::PAK::Type::PAK
@ PAK
Definition
PAK.h:26
vpkpp::PAK::Type::SIN
@ SIN
Definition
PAK.h:27
vpkpp::PAK::Type::HROT
@ HROT
Definition
PAK.h:28
vpkpp::PAK::getType
Type getType() const
Definition
PAK.cpp:169
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:164
vpkpp::PAK::getFilenameLength
uint8_t getFilenameLength() const
Definition
PAK.cpp:189
vpkpp::PAK::getSignature
uint32_t getSignature() const
Definition
PAK.cpp:177
vpkpp::PAK::type
Type type
Definition
PAK.h:56
vpkpp::PAK::addEntryInternal
void addEntryInternal(Entry &entry, const std::string &path, std::vector< std::byte > &buffer, EntryOptions options) override
Definition
PAK.cpp:98
vpkpp::PAK::setType
void setType(Type type_)
Definition
PAK.cpp:173
vpkpp::PAK::PackFile
PackFile(const PackFile &other)=delete
vpkpp::PackFile::EntryCallback
EntryCallbackBase< void > EntryCallback
Definition
PackFile.h:38
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_HROT_SIGNATURE
constexpr auto PAK_HROT_SIGNATURE
Definition
PAK.h:18
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:21
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:17
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:20
vpkpp::BakeOptions
Definition
Options.h:20
vpkpp::EntryOptions
Definition
Options.h:34
include
vpkpp
format
PAK.h
Generated on
for SourcePP by
1.16.1