util/datamanager.lua
changeset 5153 688aeac0012a
parent 5130 051d352ed03c
child 5243 07e8256efcda
--- a/util/datamanager.lua	Wed Sep 19 23:29:25 2012 +0200
+++ b/util/datamanager.lua	Fri Sep 21 17:23:08 2012 +0200
@@ -282,6 +282,25 @@
 	list = "list";
 }
 
+function users(host, store, typ)
+	typ = type_map[typ or "keyval"];
+	local store_dir = format("%s/%s/%s", data_path, encode(host), encode(store));
+
+	local mode, err = lfs.attributes(store_dir, "mode");
+	if not mode then
+		return function() log("debug", err or (store_dir .. " does not exist")) end
+	end
+	local next, state = lfs.dir(store_dir);
+	return function(state)
+		for node in next, state do
+			local file, ext = node:match("^(.*)%.([dalist]+)$");
+			if file and ext == typ then
+				return decode(file);
+			end
+		end
+	end, state;
+end
+
 function stores(username, host, typ)
 	typ = type_map[typ or "keyval"];
 	local store_dir = format("%s/%s/", data_path, encode(host));