summaryrefslogtreecommitdiffstats
path: root/acf/persistence/util.lua
diff options
context:
space:
mode:
Diffstat (limited to 'acf/persistence/util.lua')
-rw-r--r--acf/persistence/util.lua20
1 files changed, 20 insertions, 0 deletions
diff --git a/acf/persistence/util.lua b/acf/persistence/util.lua
new file mode 100644
index 0000000..46de5eb
--- /dev/null
+++ b/acf/persistence/util.lua
@@ -0,0 +1,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