SourcePP
Several modern C++20 libraries for sanely parsing Valve's formats.
Toggle main menu visibility
Loading...
Searching...
No Matches
fspp.h
Go to the documentation of this file.
1
#pragma once
2
3
#include <optional>
4
5
#include <
steampp/steampp.h
>
6
#include <
vpkpp/vpkpp.h
>
7
8
namespace
fspp
{
9
10
#if defined(_WIN32)
11
constexpr
std::string_view
DEFAULT_PLATFORM
=
"win64"
;
12
#elif defined(__APPLE__)
13
constexpr
std::string_view
DEFAULT_PLATFORM
=
"osx64"
;
14
#elif defined(__linux__)
15
constexpr
std::string_view
DEFAULT_PLATFORM
=
"linux64"
;
16
#else
17
#warning "Unknown platform! Leaving the default platform blank..."
18
constexpr
std::string_view
DEFAULT_PLATFORM
=
""
;
19
#endif
20
21
struct
FileSystemOptions
{
22
std::string
binPlatform
{
DEFAULT_PLATFORM
};
23
//std::string language{}; // todo: add a <path>_<language> dir or <path>_<language>_dir.vpk for each GAME path
24
//bool loadPakXXVPKs = true; // todo: load pakXX_dir.vpk for each dir path
25
//bool loadSteamMounts = true; // todo: cfg/mounts.kv, the mounts block in gameinfo (Strata)
26
//bool loadAddonList = false; // todo: addonlist.txt (L4D2), addonlist.kv3 (Strata)
27
//bool useDLCFolders = true; // todo: dlc1, dlc2, etc.
28
//bool useUpdate = true; // todo: mount update folder on GAME/MOD with highest priority
29
//bool useXLSPPatch = true; // todo: mount xlsppatch folder on GAME/MOD with highester priority
30
};
31
32
class
FileSystem
{
33
public
:
34
using
SearchPathMapDir
= std::unordered_map<std::string, std::vector<std::string>>;
35
using
SearchPathMapVPK
= std::unordered_map<std::string, std::vector<std::unique_ptr<vpkpp::PackFile>>>;
36
44
[[nodiscard]]
static
std::optional<FileSystem>
load
(
steampp::AppID
appID, std::string_view gameID,
const
FileSystemOptions
& options = {});
45
52
[[nodiscard]]
static
std::optional<FileSystem>
load
(std::string_view gamePath,
const
FileSystemOptions
& options = {});
53
54
[[nodiscard]]
const
SearchPathMapDir
&
getSearchPathDirs
()
const
;
55
56
[[nodiscard]]
SearchPathMapDir
&
getSearchPathDirs
();
57
58
[[nodiscard]]
const
SearchPathMapVPK
&
getSearchPathVPKs
()
const
;
59
60
[[nodiscard]]
SearchPathMapVPK
&
getSearchPathVPKs
();
61
62
[[nodiscard]] std::optional<std::vector<std::byte>>
read
(std::string_view filePath, std::string_view searchPath =
"GAME"
,
bool
prioritizeVPKs =
true
)
const
;
63
64
[[nodiscard]] std::optional<std::vector<std::byte>>
readForMap
(
const
vpkpp::PackFile
* map, std::string_view filePath, std::string_view searchPath =
"GAME"
,
bool
prioritizeVPKs =
true
)
const
;
65
66
protected
:
67
explicit
FileSystem
(std::string_view gamePath,
const
FileSystemOptions& options = {});
68
69
private
:
70
std::string rootPath;
71
SearchPathMapDir
searchPathDirs;
72
SearchPathMapVPK
searchPathVPKs;
73
};
74
75
}
// namespace fspp
fspp::FileSystem::load
static std::optional< FileSystem > load(steampp::AppID appID, std::string_view gameID, const FileSystemOptions &options={})
Creates a FileSystem based on a Steam installation.
Definition
fspp.cpp:27
fspp::FileSystem::readForMap
std::optional< std::vector< std::byte > > readForMap(const vpkpp::PackFile *map, std::string_view filePath, std::string_view searchPath="GAME", bool prioritizeVPKs=true) const
Definition
fspp.cpp:238
fspp::FileSystem::getSearchPathVPKs
const SearchPathMapVPK & getSearchPathVPKs() const
Definition
fspp.cpp:192
fspp::FileSystem::getSearchPathDirs
const SearchPathMapDir & getSearchPathDirs() const
Definition
fspp.cpp:184
fspp::FileSystem::SearchPathMapDir
std::unordered_map< std::string, std::vector< std::string > > SearchPathMapDir
Definition
fspp.h:34
fspp::FileSystem::FileSystem
FileSystem(std::string_view gamePath, const FileSystemOptions &options={})
Definition
fspp.cpp:42
fspp::FileSystem::SearchPathMapVPK
std::unordered_map< std::string, std::vector< std::unique_ptr< vpkpp::PackFile > > > SearchPathMapVPK
Definition
fspp.h:35
fspp::FileSystem::read
std::optional< std::vector< std::byte > > read(std::string_view filePath, std::string_view searchPath="GAME", bool prioritizeVPKs=true) const
Definition
fspp.cpp:200
vpkpp::PackFile
Definition
PackFile.h:26
fspp
Definition
fspp.h:8
fspp::DEFAULT_PLATFORM
constexpr std::string_view DEFAULT_PLATFORM
Definition
fspp.h:18
steampp::AppID
uint32_t AppID
Definition
steampp.h:19
steampp.h
fspp::FileSystemOptions
Definition
fspp.h:21
fspp::FileSystemOptions::binPlatform
std::string binPlatform
Definition
fspp.h:22
vpkpp.h
include
fspp
fspp.h
Generated on
for SourcePP by
1.17.0