This commit is contained in:
kepler155c
2017-10-08 17:45:37 -04:00
parent bba7841c43
commit ed2d6eeef1
23 changed files with 222 additions and 207 deletions

View File

@@ -11,14 +11,14 @@ function TableDB:init(args)
Util.merge(defaults, args)
Util.merge(self, defaults)
end
function TableDB:load()
local t = Util.readTable(self.fileName)
if t then
self.data = t.data or t
end
end
function TableDB:add(key, entry)
if type(key) == 'table' then
key = table.concat(key, ':')
@@ -26,19 +26,19 @@ function TableDB:add(key, entry)
self.data[key] = entry
self.dirty = true
end
function TableDB:get(key)
if type(key) == 'table' then
key = table.concat(key, ':')
end
return self.data[key]
end
function TableDB:remove(key)
self.data[key] = nil
self.dirty = true
end
function TableDB:flush()
if self.dirty then
Util.writeTable(self.fileName, self.data)