FileResult produces the return values for file-related functions in the standard library (io.open, os.rename, file:seek, etc.).
(l *State, err error, filename string)
| 558 | // FileResult produces the return values for file-related functions in the standard |
| 559 | // library (io.open, os.rename, file:seek, etc.). |
| 560 | func FileResult(l *State, err error, filename string) int { |
| 561 | if err == nil { |
| 562 | l.PushBoolean(true) |
| 563 | return 1 |
| 564 | } |
| 565 | l.PushNil() |
| 566 | if filename != "" { |
| 567 | l.PushString(filename + ": " + err.Error()) |
| 568 | } else { |
| 569 | l.PushString(err.Error()) |
| 570 | } |
| 571 | l.PushInteger(0) // TODO map err to errno |
| 572 | return 3 |
| 573 | } |
| 574 | |
| 575 | // DoFile loads and runs the given file. |
| 576 | func DoFile(l *State, fileName string) error { |
no test coverage detected