add 'write-to-user' permission & refactor checking for writeability

This commit is contained in:
MihailRis
2025-12-08 19:21:50 +03:00
committed by ShiftyX1
parent 8831d676d4
commit 56d808e3e2
6 changed files with 48 additions and 17 deletions
+1 -12
View File
@@ -39,18 +39,7 @@ static int l_read(lua::State* L) {
);
}
static std::set<std::string> writeable_entry_points {
"world", "export", "config"
};
static bool is_writeable(const std::string& entryPoint) {
if (entryPoint.length() < 2) {
return false;
}
if (entryPoint.substr(0, 2) == "W.") {
return true;
}
// todo: do better
auto device = io::get_device(entryPoint);
if (device == nullptr) {
return false;
@@ -58,7 +47,7 @@ static bool is_writeable(const std::string& entryPoint) {
if (dynamic_cast<io::MemoryDevice*>(device.get())) {
return true;
}
if (writeable_entry_points.find(entryPoint) != writeable_entry_points.end()) {
if (engine->getPaths().isWriteable(entryPoint)) {
return true;
}
return false;