aboutsummaryrefslogtreecommitdiff
path: root/src/database/database-files.h
diff options
context:
space:
mode:
authorJude Melton-Houghton <jwmhjwmh@gmail.com>2022-01-07 13:28:49 -0500
committerGitHub <noreply@github.com>2022-01-07 20:28:49 +0200
commitbf22569019749e421e8ffe0a73cff988a9a9c846 (patch)
tree9e6910c1faf0ddce191ad4b3110f08b0201fc482 /src/database/database-files.h
parentb81948a14c138517f6a227dac5b71f0b2facb33c (diff)
downloadminetest-bf22569019749e421e8ffe0a73cff988a9a9c846.tar.gz
minetest-bf22569019749e421e8ffe0a73cff988a9a9c846.tar.bz2
minetest-bf22569019749e421e8ffe0a73cff988a9a9c846.zip
Use a database for mod storage (#11763)
Diffstat (limited to 'src/database/database-files.h')
-rw-r--r--src/database/database-files.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/database/database-files.h b/src/database/database-files.h
index e647a2e24..962e4d7bb 100644
--- a/src/database/database-files.h
+++ b/src/database/database-files.h
@@ -25,6 +25,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "database.h"
#include <unordered_map>
+#include <unordered_set>
+#include <json/json.h>
class PlayerDatabaseFiles : public PlayerDatabase
{
@@ -69,3 +71,27 @@ private:
bool readAuthFile();
bool writeAuthFile();
};
+
+class ModMetadataDatabaseFiles : public ModMetadataDatabase
+{
+public:
+ ModMetadataDatabaseFiles(const std::string &savedir);
+ virtual ~ModMetadataDatabaseFiles() = default;
+
+ virtual bool getModEntries(const std::string &modname, StringMap *storage);
+ virtual bool setModEntry(const std::string &modname,
+ const std::string &key, const std::string &value);
+ virtual bool removeModEntry(const std::string &modname, const std::string &key);
+ virtual void listMods(std::vector<std::string> *res);
+
+ virtual void beginSave();
+ virtual void endSave();
+
+private:
+ Json::Value *getOrCreateJson(const std::string &modname);
+ bool writeJson(const std::string &modname, const Json::Value &json);
+
+ std::string m_storage_dir;
+ std::unordered_map<std::string, Json::Value> m_mod_meta;
+ std::unordered_set<std::string> m_modified;
+};