fix(fs): stop using luar, make readdir return a proper table

pull/78/head
sammyette 2021-10-17 17:26:29 -04:00
parent 7769d68859
commit 006f0f986e
No known key found for this signature in database
GPG Key ID: 50EE40A2809851F5
1 changed files with 3 additions and 4 deletions

View File

@ -9,7 +9,6 @@ import (
"hilbish/util"
"github.com/yuin/gopher-lua"
"layeh.com/gopher-luar"
)
func Loader(L *lua.LState) int {
@ -92,7 +91,7 @@ func fstat(L *lua.LState) int {
// Returns a table of files in `dir`
func freaddir(L *lua.LState) int {
dir := L.CheckString(1)
names := []string{}
names := L.NewTable()
dirEntries, err := os.ReadDir(dir)
if err != nil {
@ -100,10 +99,10 @@ func freaddir(L *lua.LState) int {
return 0
}
for _, entry := range dirEntries {
names = append(names, entry.Name())
names.Append(lua.LString(entry.Name()))
}
L.Push(luar.New(L, names))
L.Push(names)
return 1
}