MCPcopy Index your code
hub / github.com/yuin/gopher-lua / ioOutput

Function ioOutput

iolib.go:718–742  ·  view source on GitHub ↗
(L *LState)

Source from the content-addressed store, hash-verified

716}
717
718func ioOutput(L *LState) int {
719 if L.GetTop() == 0 {
720 L.Push(fileDefOut(L))
721 return 1
722 }
723 switch lv := L.Get(1).(type) {
724 case LString:
725 file, err := newFile(L, nil, string(lv), os.O_WRONLY|os.O_CREATE, 0600, true, false)
726 if err != nil {
727 L.RaiseError(err.Error())
728 }
729 L.Get(UpvalueIndex(1)).(*LTable).RawSetInt(fileDefOutIndex, file)
730 L.Push(file)
731 return 1
732 case *LUserData:
733 if _, ok := lv.Value.(*lFile); ok {
734 L.Get(UpvalueIndex(1)).(*LTable).RawSetInt(fileDefOutIndex, lv)
735 L.Push(lv)
736 return 1
737 }
738
739 }
740 L.ArgError(1, "string or file expedted, but got "+L.Get(1).Type().String())
741 return 0
742}
743
744func ioWrite(L *LState) int {
745 return fileWriteAux(L, fileDefOut(L).Value.(*lFile), 1)

Callers

nothing calls this directly

Calls 12

fileDefOutFunction · 0.85
newFileFunction · 0.85
UpvalueIndexFunction · 0.85
ArgErrorMethod · 0.80
PushMethod · 0.65
ErrorMethod · 0.65
StringMethod · 0.65
TypeMethod · 0.65
GetTopMethod · 0.45
GetMethod · 0.45
RaiseErrorMethod · 0.45
RawSetIntMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…