(L *LState)
| 716 | } |
| 717 | |
| 718 | func 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 | |
| 744 | func ioWrite(L *LState) int { |
| 745 | return fileWriteAux(L, fileDefOut(L).Value.(*lFile), 1) |
nothing calls this directly
no test coverage detected
searching dependent graphs…