[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [proposal] close file on io.lines("filename", "*a")()
- From: Sergey Kovalev <kovserg33@...>
- Date: Tue, 30 Jul 2019 22:44:59 +0300
вт, 30 июл. 2019 г. в 20:44, Soni "They/Them" L. <fakedme@gmail.com>:
> compare to:
> io.open("filename"):read("*a")
You can write simple function
function file_get_contents(name,mode)
local f,r=io.open(name,mode or "rb")
if f then r=f:read"a" else error(r) end
f:close()
return r
end
And read whole file just in one call file_get_contents
mydata=file_get_contents "myfile"