summaryrefslogtreecommitdiffstats
path: root/acf/persistence/util.lua
blob: 46de5eb92515d6807aaf1b2bb2855b3f7b9d3b16 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
--[[
Copyright (c) 2012 Kaarle Ritvanen
See LICENSE file for license details
--]]

module(..., package.seeall)

function open_file(path, mode)
   local file = io.open(path, mode)
   if not file then error('Cannot open file: '..path) end
   return file
end

function read_file(path)
   local file = open_file(path)
   local data = ''
   for line in file:lines() do data = data..line end
   file:close()
   return data
end