diff options
Diffstat (limited to 'acf2/persistence/util.lua')
-rw-r--r-- | acf2/persistence/util.lua | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/acf2/persistence/util.lua b/acf2/persistence/util.lua new file mode 100644 index 0000000..a657411 --- /dev/null +++ b/acf2/persistence/util.lua @@ -0,0 +1,22 @@ +--[[ +Copyright (c) 2012-2013 Kaarle Ritvanen +See LICENSE file for license details +--]] + +local M = {} + +function M.open_file(path, mode) + local file = io.open(path, mode) + if not file then error('Cannot open file: '..path) end + return file +end + +function M.read_file(path) + local file = M.open_file(path) + local data = '' + for line in file:lines() do data = data..line end + file:close() + return data +end + +return M |