mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-06-06 02:58:18 -04:00
42d412a06e
Mods can now replace DVD files with contents of their "overlay" folder (I'll update the docs later when I do a full pass and make non-code mods more of a first-class citizen) Fixes https://github.com/TwilitRealm/dusklight/issues/1306
45 lines
1.2 KiB
C++
45 lines
1.2 KiB
C++
#pragma once
|
|
|
|
#include <filesystem>
|
|
#include "miniz.h"
|
|
|
|
namespace dusk::modding {
|
|
|
|
class ModBundle {
|
|
public:
|
|
virtual ~ModBundle() = default;
|
|
|
|
virtual std::vector<u8> readFile(const std::string& fileName) = 0;
|
|
virtual std::vector<std::string> getFileNames() = 0;
|
|
virtual size_t getFileSize(const std::string& fileName) = 0;
|
|
};
|
|
|
|
class ModBundleZip final : public ModBundle {
|
|
public:
|
|
explicit ModBundleZip(std::vector<u8>&& data);
|
|
~ModBundleZip() override;
|
|
std::vector<u8> readFile(const std::string& fileName) override;
|
|
std::vector<std::string> getFileNames() override;
|
|
size_t getFileSize(const std::string& fileName) override;
|
|
|
|
private:
|
|
std::vector<uint8_t> zip_data;
|
|
mz_zip_archive res_zip{};
|
|
bool res_zip_open = false;
|
|
};
|
|
|
|
class ModBundleDisk final : public ModBundle {
|
|
public:
|
|
explicit ModBundleDisk(std::filesystem::path root);
|
|
~ModBundleDisk() override = default;
|
|
std::vector<u8> readFile(const std::string& fileName) override;
|
|
std::vector<std::string> getFileNames() override;
|
|
size_t getFileSize(const std::string& fileName) override;
|
|
|
|
private:
|
|
[[nodiscard]] std::filesystem::path toRealPath(const std::string& fileName) const;
|
|
std::filesystem::path root_path;
|
|
};
|
|
|
|
} // namespace dusk::modding
|