Changeset

2444:267d6482bac6

util.datamanager: Use pposix.mkdir if available
author Matthew Wild <mwild1@gmail.com>
date Sun, 10 Jan 2010 23:13:30 +0000
parents 2443:b335ae55af77
children 2445:9806fac994f8
files util/datamanager.lua
diffstat 1 files changed, 9 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/util/datamanager.lua	Sun Jan 10 23:12:22 2010 +0000
+++ b/util/datamanager.lua	Sun Jan 10 23:13:30 2010 +0000
@@ -21,13 +21,19 @@
 local t_insert = table.insert;
 local append = require "util.serialization".append;
 local path_separator = "/"; if os.getenv("WINDIR") then path_separator = "\\" end
-local lfs_mkdir = require "lfs".mkdir;
+local raw_mkdir;
+
+if prosody.platform == "posix" then
+	raw_mkdir = require "util.pposix".mkdir; -- Doesn't trample on umask
+else
+	raw_mkdir = require "lfs".mkdir;
+end
 
 module "datamanager"
 
 ---- utils -----
 local encode, decode;
-do 
+do
 	local urlcodes = setmetatable({}, { __index = function (t, k) t[k] = char(tonumber("0x"..k)); return t[k]; end });
 
 	decode = function (s)
@@ -43,7 +49,7 @@
 local function mkdir(path)
 	path = path:gsub("/", path_separator); -- TODO as an optimization, do this during path creation rather than here
 	if not _mkdir[path] then
-		lfs_mkdir(path);
+		raw_mkdir(path);
 		_mkdir[path] = true;
 	end
 	return path;