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

Function newFile

iolib.go:65–84  ·  view source on GitHub ↗
(L *LState, file *os.File, path string, flag int, perm os.FileMode, writable, readable bool)

Source from the content-addressed store, hash-verified

63}
64
65func newFile(L *LState, file *os.File, path string, flag int, perm os.FileMode, writable, readable bool) (*LUserData, error) {
66 ud := L.NewUserData()
67 var err error
68 if file == nil {
69 file, err = os.OpenFile(path, flag, perm)
70 if err != nil {
71 return nil, err
72 }
73 }
74 lfile := &lFile{fp: file, pp: nil, writer: nil, reader: nil, stdout: nil, closed: false}
75 ud.Value = lfile
76 if writable {
77 lfile.writer = file
78 }
79 if readable {
80 lfile.reader = bufio.NewReaderSize(file, fileDefaultReadBuffer)
81 }
82 L.SetMetatable(ud, L.GetTypeMetatable(lFileClass))
83 return ud, nil
84}
85
86func newProcess(L *LState, cmd string, writable, readable bool) (*LUserData, error) {
87 ud := L.NewUserData()

Callers 6

OpenIoFunction · 0.85
ioInputFunction · 0.85
ioLinesFunction · 0.85
ioOpenFileFunction · 0.85
ioTmpFileFunction · 0.85
ioOutputFunction · 0.85

Calls 3

GetTypeMetatableMethod · 0.80
NewUserDataMethod · 0.45
SetMetatableMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…