summaryrefslogtreecommitdiff
path: root/meta/template/io.lua
blob: 1576c2b63832bb208a40df10cf3f477c062873c0 (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
---@meta

---@class io
---@field stdin  file
---@field stdout file
---@field stderr file
io = {}

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

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

function io.flush() end

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

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

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

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

---@alias popenmode
---| '"r"'
---| '"w"'

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

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

---@return file
function io.tmpfile() end

---@alias filetype
---| '"file"'
---| '"closed file"'
---| 'nil'
---@param file file
---@return filetype
function io.type(file) end

---@return file
---@return string errmsg?
function io.write(...) end

return io