mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-10-04 19:37:23 -04:00
e964f7f8e2
Now implicitly handles .lua files on top of .luau.
Also handles directory/init.lua(u) when doing require("directory")
cases of conflict (both .lua and .luau, or both .luau and directory) report an error
For reference: https://github.com/luau-lang/rfcs/blob/79c722717ffd96e5c5b5a9493ff01fda8a5171be/docs/amended-require-resolution.md
Fixes https://github.com/TwilitRealm/dusklight/issues/2406
34 lines
874 B
C++
34 lines
874 B
C++
#include "loader.hpp"
|
|
|
|
#include <stdexcept>
|
|
|
|
namespace dusk::mods {
|
|
|
|
ModBundleZip::ModBundleZip(const std::filesystem::path& path) : m_archive{path} {
|
|
if (m_archive.package_format() != archive::PackageFormat::Mod) {
|
|
throw std::runtime_error("Archive is not a valid mod package");
|
|
}
|
|
}
|
|
|
|
std::vector<u8> ModBundleZip::readFile(const std::string& fileName) {
|
|
return m_archive.read_file(fileName);
|
|
}
|
|
|
|
std::vector<std::string> ModBundleZip::getFileNames() {
|
|
return m_archive.file_names();
|
|
}
|
|
|
|
size_t ModBundleZip::getFileSize(const std::string& fileName) {
|
|
return m_archive.file_size(fileName);
|
|
}
|
|
|
|
bool ModBundleZip::file_exists(const std::string& fileName) {
|
|
return m_archive.file_exists(fileName);
|
|
}
|
|
|
|
bool ModBundleZip::directory_exists(const std::string& fileName) {
|
|
return m_archive.directory_exists(fileName);
|
|
}
|
|
|
|
} // namespace dusk::mods
|