make App.open_for_* look more like io.open

Now missing files will result in similar behavior: nil file handles.
This commit is contained in:
Kartik K. Agaram 2022-08-23 13:11:52 -07:00
parent b6f42ebf01
commit 019a829279
1 changed files with 9 additions and 7 deletions

16
app.lua
View File

@ -302,13 +302,15 @@ function App.open_for_writing(filename)
end
function App.open_for_reading(filename)
return {
lines = function(self)
return App.filesystem[filename]:gmatch('[^\n]+')
end,
close = function(self)
end,
}
if App.filesystem[filename] then
return {
lines = function(self)
return App.filesystem[filename]:gmatch('[^\n]+')
end,
close = function(self)
end,
}
end
end
function App.run_tests()