Open ajloveslily14 opened 6 years ago
i'd honestly love for the file. functions to just wrap over the default io. code i don't think it'd ever happen but it'd be great
Well, it would have to be modified anyways to not allow files being read from anywhere.
local f = file.Open("file.txt","wr", "DATA")
while true do
local line = f:ReadLine()
if line == nil then break end
end
f:Close()
I'm assuming ReadLine returns nil at eof, but not sure.
Does ReadLine automatically skip to the next line?
yea. any of the Read* functions advance the file position.
Theres a buffer limit on the ReadLine function though, check the wiki for details.
I see. That's nice though I don't really like reinventing wheels heh
One more example:
for line in f.ReadLine,f do
end
In 'vanilla' lua there's an iterator for lines in files eg:
Currently in glua there is no such iterator and you have to make your own, with something like
lines = string.Explode("\n",file)
and then iterate through that table, which does work however can be cumbersome.