aboutsummaryrefslogtreecommitdiff
path: root/diller/cfg.lua
diff options
context:
space:
mode:
Diffstat (limited to 'diller/cfg.lua')
-rw-r--r--diller/cfg.lua36
1 files changed, 36 insertions, 0 deletions
diff --git a/diller/cfg.lua b/diller/cfg.lua
new file mode 100644
index 0000000..2a8472c
--- /dev/null
+++ b/diller/cfg.lua
@@ -0,0 +1,36 @@
+function info(msg)
+ print("info msg="..msg)
+end
+
+function read_cfg(name, required)
+ local filename = "cfg-"..name
+ if not file.open(filename, "r") then
+ if required then
+ panic("Could not read configuration file: "..filename)
+ else
+ return nil
+ end
+ end
+ local value = file.readline()
+ file.close()
+ if value == nil or #value == 0 then
+ if required then
+ panic("Empty configuration file: "..filename)
+ else
+ return nil
+ end
+ end
+ return string.sub(value, 1, -2)
+end
+
+function write_cfg(name, value)
+ local filename = "cfg-"..name
+ local ok
+ ok = file.open(filename, "w+")
+ if ok then
+ ok = file.writeline(value)
+ file.flush()
+ file.close()
+ end
+ return ok
+end