summaryrefslogtreecommitdiff
path: root/meta/template/io.lua
blob: bc47f56dc711a549e2e18dee17ec8a9ea2596252 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
---@meta

---#DES 'io'
---@class iolib
---#DES 'io.stdin'
---@field stdin  file*
---#DES 'io.stdout'
---@field stdout file*
---#DES 'io.stderr'
---@field stderr file*
io = {}

---@alias openmode
---|>'"r"'   # ---#DESTAIL 'openmode.r'
---| '"w"'   # ---#DESTAIL 'openmode.w'
---| '"a"'   # ---#DESTAIL 'openmode.a'
---| '"r+"'  # ---#DESTAIL 'openmode.r+'
---| '"w+"'  # ---#DESTAIL 'openmode.w+'
---| '"a+"'  # ---#DESTAIL 'openmode.a+'
---| '"rb"'  # ---#DESTAIL 'openmode.rb'
---| '"wb"'  # ---#DESTAIL 'openmode.wb'
---| '"ab"'  # ---#DESTAIL 'openmode.ab'
---| '"r+b"' # ---#DESTAIL 'openmode.r+b'
---| '"w+b"' # ---#DESTAIL 'openmode.w+b'
---| '"a+b"' # ---#DESTAIL 'openmode.a+b'

---#DES 'io.close'
---@param file? file*
---@return boolean?  suc
---@return exitcode? exitcode
---@return integer?  code
function io.close(file) end

---#DES 'io.flush'
function io.flush() end

---#DES 'io.input'
---@overload fun():file*
---@param file string|file*
function io.input(file) end

---#DES 'io.lines'
---@param filename string?
---@vararg readmode
---@return fun():string|number
function io.lines(filename, ...) end

---#DES 'io.open'
---@param filename string
---@param mode     openmode
---@return file*?
---@return string? errmsg
function io.open(filename, mode) end

---#DES 'io.output'
---@overload fun():file*
---@param file string|file*
function io.output(file) end

---@alias popenmode
---| '"r"' # ---#DESTAIL 'popenmode.r'
---| '"w"' # ---#DESTAIL 'popenmode.w'

---#DES 'io.popen'
---@param prog  string
---@param mode? popenmode
---@return file*?
---@return string? errmsg
function io.popen(prog, mode) end

---#DES 'io.read'
---@vararg readmode
---@return string|number
---@return ...
function io.read(...) end

---#DES 'io.tmpfile'
---@return file*
function io.tmpfile() end

---@alias filetype
---| '"file"'        # ---#DESTAIL 'filetype.file'
---| '"closed file"' # ---#DESTAIL 'filetype.closed file'
---| 'nil'           # ---#DESTAIL 'filetype.nil'

---#DES 'io.type'
---@param file file*
---@return filetype
function io.type(file) end

---#DES 'io.write'
---@return file*
---@return string? errmsg
function io.write(...) end

return io