MCPcopy
hub / github.com/yuin/gopher-lua / baseLoadFile

Function baseLoadFile

baselib.go:198–216  ·  view source on GitHub ↗
(L *LState)

Source from the content-addressed store, hash-verified

196}
197
198func baseLoadFile(L *LState) int {
199 var reader io.Reader
200 var chunkname string
201 var err error
202 if L.GetTop() < 1 {
203 reader = os.Stdin
204 chunkname = "<stdin>"
205 } else {
206 chunkname = L.CheckString(1)
207 reader, err = os.Open(chunkname)
208 if err != nil {
209 L.Push(LNil)
210 L.Push(LString(fmt.Sprintf("can not open file: %v", chunkname)))
211 return 2
212 }
213 defer reader.(*os.File).Close()
214 }
215 return loadaux(L, reader, chunkname)
216}
217
218func baseLoadString(L *LState) int {
219 return loadaux(L, strings.NewReader(L.CheckString(1)), L.OptString(2, "<string>"))

Callers

nothing calls this directly

Calls 6

LStringTypeAlias · 0.85
loadauxFunction · 0.85
CheckStringMethod · 0.80
PushMethod · 0.65
GetTopMethod · 0.45
CloseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…