Skip to content

Instantly share code, notes, and snippets.

@altexy
Created August 8, 2018 12:54
Show Gist options
  • Save altexy/06e699d03492a822a9579873488c1055 to your computer and use it in GitHub Desktop.
Save altexy/06e699d03492a822a9579873488c1055 to your computer and use it in GitHub Desktop.
Lua read file
local function read_file(path)
local file = io_open(path, "rb") -- r read mode and b binary mode
if not file then return nil, "Cannot open file: " .. path end
local content = file:read "*a" -- *a or *all reads the whole file
file:close()
return content
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment