Mod file overlay system

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
This commit is contained in:
PJB3005
2026-05-15 21:04:42 +02:00
parent 37e5b7409d
commit 42d412a06e
7 changed files with 138 additions and 3 deletions
+10 -3
View File
@@ -9,10 +9,8 @@ namespace dusk::modding {
ModBundleDisk::ModBundleDisk(fs::path root) : root_path(std::move(root)) {}
std::vector<u8> ModBundleDisk::readFile(const std::string& fileName) {
const fs::path filePath = reinterpret_cast<const char8_t*>(fileName.c_str());
const auto finalPath = root_path / fileName;
return io::FileStream::ReadAllBytes(finalPath);
return io::FileStream::ReadAllBytes(toRealPath(fileName));
}
std::vector<std::string> ModBundleDisk::getFileNames() {
@@ -51,4 +49,13 @@ std::vector<std::string> ModBundleDisk::getFileNames() {
return files;
}
size_t ModBundleDisk::getFileSize(const std::string& fileName) {
return std::filesystem::file_size(toRealPath(fileName));
}
std::filesystem::path ModBundleDisk::toRealPath(const std::string& fileName) const {
const fs::path filePath = reinterpret_cast<const char8_t*>(fileName.c_str());
return root_path / fileName;
}
} // namespace dusk::modding