feat: add option for fs.mkdir to make recursive

pull/61/head
sammyette 2021-06-12 09:31:42 -04:00
parent cd06c61195
commit fb04322844
No known key found for this signature in database
GPG Key ID: 50EE40A2809851F5
1 changed files with 7 additions and 1 deletions

View File

@ -47,9 +47,15 @@ func cd(L *lua.LState) int {
func mkdir(L *lua.LState) int { func mkdir(L *lua.LState) int {
dirname := L.CheckString(1) dirname := L.CheckString(1)
recursive := L.ToBool(2)
path := strings.TrimSpace(dirname)
// TODO: handle error here // TODO: handle error here
os.Mkdir(strings.TrimSpace(dirname), 0744) if recursive {
os.MkdirAll(path, 0744)
} else {
os.Mkdir(path, 0744)
}
return 0 return 0
} }