mirror of
https://github.com/Hilbis/Hilbish
synced 2025-03-30 18:23:23 +00:00
fix(fs): stop using luar, make readdir return a proper table
This commit is contained in:
parent
7769d68859
commit
006f0f986e
@ -9,7 +9,6 @@ import (
|
|||||||
|
|
||||||
"hilbish/util"
|
"hilbish/util"
|
||||||
"github.com/yuin/gopher-lua"
|
"github.com/yuin/gopher-lua"
|
||||||
"layeh.com/gopher-luar"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func Loader(L *lua.LState) int {
|
func Loader(L *lua.LState) int {
|
||||||
@ -92,7 +91,7 @@ func fstat(L *lua.LState) int {
|
|||||||
// Returns a table of files in `dir`
|
// Returns a table of files in `dir`
|
||||||
func freaddir(L *lua.LState) int {
|
func freaddir(L *lua.LState) int {
|
||||||
dir := L.CheckString(1)
|
dir := L.CheckString(1)
|
||||||
names := []string{}
|
names := L.NewTable()
|
||||||
|
|
||||||
dirEntries, err := os.ReadDir(dir)
|
dirEntries, err := os.ReadDir(dir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -100,10 +99,10 @@ func freaddir(L *lua.LState) int {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
for _, entry := range dirEntries {
|
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
|
return 1
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user