mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-06 11:31:49 +00:00
fixes
This commit is contained in:
parent
2a8fa4f2fa
commit
536035441a
5 changed files with 26 additions and 3 deletions
|
|
@ -4,12 +4,16 @@
|
|||
#include "io/devices/MemoryDevice.hpp"
|
||||
|
||||
static int l_create_memory_device(lua::State* L) {
|
||||
auto name = lua::require_string(L, 1);
|
||||
std::string name = lua::require_string(L, 1);
|
||||
if (io::get_device(name)) {
|
||||
throw std::runtime_error(
|
||||
"entry-point '" + std::string(name) + "' is already used"
|
||||
"entry-point '" + name + "' is already used"
|
||||
);
|
||||
}
|
||||
if (name.find(':') != std::string::npos) {
|
||||
throw std::runtime_error("invalid entry point name");
|
||||
}
|
||||
|
||||
io::set_device(name, std::make_unique<io::MemoryDevice>());
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
#include "engine/Engine.hpp"
|
||||
#include "engine/EnginePaths.hpp"
|
||||
#include "io/io.hpp"
|
||||
#include "io/devices/MemoryDevice.hpp"
|
||||
#include "io/devices/ZipFileDevice.hpp"
|
||||
#include "util/stringutil.hpp"
|
||||
#include "api_lua.hpp"
|
||||
|
|
@ -49,6 +50,14 @@ static bool is_writeable(const std::string& entryPoint) {
|
|||
if (entryPoint.substr(0, 2) == "W.") {
|
||||
return true;
|
||||
}
|
||||
// todo: do better
|
||||
auto device = io::get_device(entryPoint);
|
||||
if (device == nullptr) {
|
||||
return false;
|
||||
}
|
||||
if (dynamic_cast<io::MemoryDevice*>(device.get())) {
|
||||
return true;
|
||||
}
|
||||
if (writeable_entry_points.find(entryPoint) != writeable_entry_points.end()) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue