SourcePP
Several modern C++20 libraries for sanely parsing Valve's formats.
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
8namespace 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
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
33public:
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
66protected:
67 explicit FileSystem(std::string_view gamePath, const FileSystemOptions& options = {});
68
69private:
70 std::string rootPath;
71 SearchPathMapDir searchPathDirs;
72 SearchPathMapVPK searchPathVPKs;
73};
74
75} // namespace fspp
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
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
const SearchPathMapVPK & getSearchPathVPKs() const
Definition: fspp.cpp:192
const SearchPathMapDir & getSearchPathDirs() const
Definition: fspp.cpp:184
std::unordered_map< std::string, std::vector< std::string > > SearchPathMapDir
Definition: fspp.h:34
std::unordered_map< std::string, std::vector< std::unique_ptr< vpkpp::PackFile > > > SearchPathMapVPK
Definition: fspp.h:35
std::optional< std::vector< std::byte > > read(std::string_view filePath, std::string_view searchPath="GAME", bool prioritizeVPKs=true) const
Definition: fspp.cpp:200
Definition: fspp.h:8
constexpr std::string_view DEFAULT_PLATFORM
Definition: fspp.h:18
uint32_t AppID
Definition: steampp.h:17
std::string binPlatform
Definition: fspp.h:22