2016-12-11 19:24:52 +00:00
|
|
|
local Util = require('util')
|
|
|
|
|
2017-10-08 21:45:01 +00:00
|
|
|
local fs = _G.fs
|
|
|
|
|
2016-12-11 19:24:52 +00:00
|
|
|
local Config = { }
|
|
|
|
|
|
|
|
Config.load = function(fname, data)
|
2017-05-20 22:27:26 +00:00
|
|
|
local filename = 'usr/config/' .. fname
|
2016-12-11 19:24:52 +00:00
|
|
|
|
2017-05-20 22:27:26 +00:00
|
|
|
if not fs.exists('usr/config') then
|
|
|
|
fs.makeDir('usr/config')
|
2016-12-11 19:24:52 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
if not fs.exists(filename) then
|
|
|
|
Util.writeTable(filename, data)
|
|
|
|
else
|
|
|
|
Util.merge(data, Util.readTable(filename) or { })
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
Config.update = function(fname, data)
|
2017-05-20 22:27:26 +00:00
|
|
|
local filename = 'usr/config/' .. fname
|
2016-12-11 19:24:52 +00:00
|
|
|
Util.writeTable(filename, data)
|
|
|
|
end
|
|
|
|
|
|
|
|
return Config
|