Changeset

452:613c5c6bdce4

Added option core.data_path
author Waqas Hussain <waqas20@gmail.com>
date Fri, 28 Nov 2008 20:17:20 +0500
parents 449:c0a4a1e63d70
children 453:a1efb2cb4f9c
files main.lua util/datamanager.lua
diffstat 2 files changed, 11 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/main.lua	Fri Nov 28 01:16:26 2008 +0500
+++ b/main.lua	Fri Nov 28 20:17:20 2008 +0500
@@ -24,6 +24,8 @@
 	end
 end
 
+require "util.datamanager".set_data_path(config.get("*", "core", "data_path") or "data");
+
 local server = require "net.server"
 
 require "util.dependencies"
--- a/util/datamanager.lua	Fri Nov 28 01:16:26 2008 +0500
+++ b/util/datamanager.lua	Fri Nov 28 20:17:20 2008 +0500
@@ -17,6 +17,8 @@
 	end
 end
 
+local data_path = "data";
+
 module "datamanager"
 
 
@@ -70,14 +72,18 @@
 
 ------- API -------------
 
+function set_data_path(path)
+	data_path = path;
+end
+
 function getpath(username, host, datastore, ext)
 	ext = ext or "dat";
 	if username then
-		return format("data/%s/%s/%s.%s", encode(host), datastore, encode(username), ext);
+		return format("%s/%s/%s/%s.%s", data_path, encode(host), datastore, encode(username), ext);
 	elseif host then
-		return format("data/%s/%s.%s", encode(host), datastore, ext);
+		return format("%s/%s/%s.%s", data_path, encode(host), datastore, ext);
 	else
-		return format("data/%s.%s", datastore, ext);
+		return format("%s/%s.%s", data_path, datastore, ext);
 	end
 end