summaryrefslogtreecommitdiff
path: root/meta/template/file.lua
blob: 8d826ac103d09c3a0d94dce1d70066c0593821c1 (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
---@meta

---#DES 'file'
---@class file*
local file = {}

---@alias readmode number
---#if VERSION >= 5.3 then
---| '"n"'  # ---#DESTAIL 'readmode.n'
---| '"a"'  # ---#DESTAIL 'readmode.a'
---|>'"l"'  # ---#DESTAIL 'readmode.l'
---| '"L"'  # ---#DESTAIL 'readmode.L'
---#else
---| '"*n"' # ---#DESTAIL 'readmode.n'
---| '"*a"' # ---#DESTAIL 'readmode.a'
---|>'"*l"' # ---#DESTAIL 'readmode.l'
---#if JIT then
---| '"*L"' # ---#DESTAIL 'readmode.L'
---#end
---#end

---@alias exitcode | '"exit"'|'"signal"'

---#DES 'file:close'
---@return boolean?  suc
---@return exitcode? exitcode
---@return integer?  code
function file:close() end

---#DES 'file:flush'
function file:flush() end

---#DES 'file:lines'
---@vararg readmode
---@return fun():string|number
function file:lines(...) end

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

---@alias seekwhence
---| '"set"' # ---#DESTAIL 'seekwhence.set'
---|>'"cur"' # ---#DESTAIL 'seekwhence.cur'
---| '"end"' # ---#DESTAIL 'seekwhence.end'

---#DES 'file:seek'
---@param whence? seekwhence
---@param offset? integer
---@return integer offset
---@return string? errmsg
function file:seek(whence, offset) end

---@alias vbuf
---| '"no"'   # ---#DESTAIL 'vbuf.no'
---| '"full"' # ---#DESTAIL 'vbuf.full'
---| '"line"' # ---#DESTAIL 'vbuf.line'

---#DES 'file:setvbuf'
---@param mode vbuf
---@param size integer
function file:setvbuf(mode, size) end

---#DES 'file:write'
---@vararg string|number
---@return file*?
---@return string? errmsg
function file:write(...) end