os.mkdir(path, perm) lua function added

This commit is contained in:
2025-08-02 16:29:42 -03:00
parent 69e7de6312
commit 6708f705ee
2 changed files with 22 additions and 0 deletions

View File

@@ -366,3 +366,22 @@ func Ljoin(L *lua.LState) int {
L.Push(lua.LString(result))
return 1
}
func LMkdir(L *lua.LState) int {
path := L.CheckString(1)
perm := L.CheckInt(2)
if !IsSafe(path) {
L.Push(lua.LFalse)
L.Push(lua.LString("[packets] unsafe filepath\n"))
}
if err := os.MkdirAll(path, os.FileMode(perm)); err != nil {
L.Push(lua.LFalse)
L.Push(lua.LString("[packets] mkdir failed\n" + err.Error()))
}
L.Push(lua.LTrue)
L.Push(lua.LNil)
return 2
}