Limo
A simple mod manager
Loading...
Searching...
No Matches
bg3pakfile.h
Go to the documentation of this file.
1
5
6#pragma once
7
8#include "bg3plugin.h"
9#include <filesystem>
10#include <json/json.h>
11
12
17{
18public:
20 Bg3PakFile() = default;
25 Bg3PakFile(const std::filesystem::path& source_file, const std::filesystem::path& prefix);
30 Bg3PakFile(const Json::Value& json_value, const std::filesystem::path& prefix);
31
36 const std::vector<Bg3Plugin>& getPlugins() const;
41 Json::Value toJson() const;
46 std::filesystem::path getSourceFile() const;
51 bool timestampsMatch();
57 std::string getPluginName(const std::string& uuid) const;
63 bool hasPlugin(const std::string& uuid) const;
71 bool pluginConflictsWith(const std::string& plugin_uuid,
72 const Bg3PakFile& other_file,
73 const std::string& other_plugin_uuid);
79 bool conflictsWith(const Bg3PakFile& other);
80
81 private :
83 std::vector<Bg3Plugin> plugins_;
85 std::filesystem::path source_file_;
87 std::time_t modified_time_;
89 std::vector<std::filesystem::path> file_list_;
91 std::filesystem::path source_path_prefix_;
92
94 void init();
96 std::time_t getTimestamp(const std::filesystem::path& file);
97};
Header for the Bg3Plugin class.
Bg3PakFile(const std::filesystem::path &source_file, const std::filesystem::path &prefix)
Reads all plugins from the given .pak file.
std::string getPluginName(const std::string &uuid) const
Returns the name of the plugin matching the given UUID.
Definition bg3pakfile.cpp:63
bool pluginConflictsWith(const std::string &plugin_uuid, const Bg3PakFile &other_file, const std::string &other_plugin_uuid)
Checks whether the given plugin conflicts with the given plugin in the given file.
Definition bg3pakfile.cpp:76
Bg3PakFile(const Json::Value &json_value, const std::filesystem::path &prefix)
Deserializes data from the given json object.
std::filesystem::path source_file_
Path to the source file.
Definition bg3pakfile.h:85
Json::Value toJson() const
Serializes this object.
Definition bg3pakfile.cpp:41
const std::vector< Bg3Plugin > & getPlugins() const
Returns a vector of plugins contained in this pak file.
Definition bg3pakfile.cpp:36
Bg3PakFile()=default
Default constructor.
std::filesystem::path getSourceFile() const
Returns the path to this object's source file.
Definition bg3pakfile.cpp:53
std::filesystem::path source_path_prefix_
Prefix for the source file path.
Definition bg3pakfile.h:91
bool conflictsWith(const Bg3PakFile &other)
Checks whether the any files conflcits with the given pak archive.
Definition bg3pakfile.cpp:118
std::time_t modified_time_
Time at which the source file was modified.
Definition bg3pakfile.h:87
bool hasPlugin(const std::string &uuid) const
Checks whether a plugin with the given UUID exists.
Definition bg3pakfile.cpp:71
std::time_t getTimestamp(const std::filesystem::path &file)
Reads the file modification time from the given file.
Definition bg3pakfile.cpp:128
std::vector< Bg3Plugin > plugins_
Contains all plugins in the source file.
Definition bg3pakfile.h:83
bool timestampsMatch()
Checks if this file's timestamp matches the modification time on disk.
Definition bg3pakfile.cpp:58
void init()
Initializes this object from the source file.
Definition bg3pakfile.cpp:134
std::vector< std::filesystem::path > file_list_
Contains paths to files in the source file.
Definition bg3pakfile.h:89