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

View File

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