summaryrefslogtreecommitdiffstats
path: root/acf/persistence
diff options
context:
space:
mode:
authorKaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>2013-05-01 11:44:11 +0300
committerKaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>2013-05-01 14:11:00 +0300
commitb5cf596d6c17fc9c8b7c679fe445a9c70af2a16e (patch)
treeaa649c1ff98961f1b6bbc1fef983a8ee9adc1c07 /acf/persistence
parent8a1ecf4ef917a47119c269f3adcf78cf082e0e55 (diff)
downloadaconf-b5cf596d6c17fc9c8b7c679fe445a9c70af2a16e.tar.bz2
aconf-b5cf596d6c17fc9c8b7c679fe445a9c70af2a16e.tar.xz
allow numerical components in path names
use escape syntax to encode number-looking strings
Diffstat (limited to 'acf/persistence')
-rw-r--r--acf/persistence/backends/augeas.lua2
-rw-r--r--acf/persistence/backends/files.lua6
-rw-r--r--acf/persistence/backends/json.lua4
-rw-r--r--acf/persistence/backends/volatile.lua4
4 files changed, 8 insertions, 8 deletions
diff --git a/acf/persistence/backends/augeas.lua b/acf/persistence/backends/augeas.lua
index c33e09a..d3fff0f 100644
--- a/acf/persistence/backends/augeas.lua
+++ b/acf/persistence/backends/augeas.lua
@@ -13,7 +13,7 @@ backend = require('acf.object').class()
function backend:init() self.aug = require('augeas').init() end
function backend:get(path, tpe)
- path = '/'..pth.mjoin(unpack(path))
+ path = pth.join('/', unpack(path))
local _, count = self.aug:match(path)
if count == 0 then return end
diff --git a/acf/persistence/backends/files.lua b/acf/persistence/backends/files.lua
index 03eadff..e123e21 100644
--- a/acf/persistence/backends/files.lua
+++ b/acf/persistence/backends/files.lua
@@ -17,7 +17,7 @@ backend = require('acf.object').class()
function backend:init() self.cache = {} end
function backend:get(path, tpe)
- local name = pth.mjoin('/', unpack(path))
+ local name = pth.join('/', unpack(path))
if not self.cache[name] then
local t = posix.stat(name, 'type')
@@ -30,7 +30,7 @@ function backend:get(path, tpe)
local res = {}
for _, fname in ipairs(posix.dir(name)) do
if not ({['.']=true, ['..']=true})[fname] then
- table.insert(res, fname)
+ table.insert(res, pth.name(fname))
end
end
return res
@@ -46,7 +46,7 @@ end
function backend:set(mods)
for _, mod in pairs(mods) do
local path, t, value = unpack(mod)
- local name = pth.mjoin('/', unpack(path))
+ local name = pth.join('/', unpack(path))
-- TODO save references (t == 'reference') as symlinks
diff --git a/acf/persistence/backends/json.lua b/acf/persistence/backends/json.lua
index 57352d8..65fc987 100644
--- a/acf/persistence/backends/json.lua
+++ b/acf/persistence/backends/json.lua
@@ -28,7 +28,7 @@ function backend:split_path(path)
local res
while #fpath > 0 do
- local fp = pth.mjoin('/', unpack(fpath))
+ local fp = pth.join('/', unpack(fpath))
if self.cache[fp] then return fp, jpath end
table.insert(jpath, 1, fpath[#fpath])
table.remove(fpath)
@@ -37,7 +37,7 @@ function backend:split_path(path)
fpath = '/'
while true do
- fpath = pth.mjoin(fpath, jpath[1])
+ fpath = pth.join(fpath, jpath[1])
table.remove(jpath, 1)
local t = posix.stat(fpath, 'type')
diff --git a/acf/persistence/backends/volatile.lua b/acf/persistence/backends/volatile.lua
index 165e7fc..339f937 100644
--- a/acf/persistence/backends/volatile.lua
+++ b/acf/persistence/backends/volatile.lua
@@ -24,7 +24,7 @@ function backend:_get(path)
for _, comp in ipairs(path) do
if res == nil then return end
assert(type(res) == 'table')
- res = res[tonumber(comp) or comp]
+ res = res[comp]
end
return res
end
@@ -43,7 +43,7 @@ function backend:_set(path, tpe, value)
local comps = copy(path)
local name = comps[#comps]
table.remove(comps)
- self:_get(comps)[tonumber(name) or name] = value
+ self:_get(comps)[name] = value
end
end