aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWaqas Hussain <waqas20@gmail.com>2012-09-12 22:03:06 +0500
committerWaqas Hussain <waqas20@gmail.com>2012-09-12 22:03:06 +0500
commita79c507ade52c12c691a1eb79fbf80f0cba5be77 (patch)
treee71fdd4f2fc3d1b5ec106ea03aa9294f4fade4e5
parent7deb430dfce27416d143c645fbc2b7fc10bf1f01 (diff)
downloadprosody-a79c507ade52c12c691a1eb79fbf80f0cba5be77.tar.gz
prosody-a79c507ade52c12c691a1eb79fbf80f0cba5be77.zip
util.datamanager: Make the util.pposix dependency optional.
-rw-r--r--util/datamanager.lua35
1 files changed, 15 insertions, 20 deletions
diff --git a/util/datamanager.lua b/util/datamanager.lua
index 17c614ed..e6ad86db 100644
--- a/util/datamanager.lua
+++ b/util/datamanager.lua
@@ -25,28 +25,23 @@ local serialize = require "util.serialization".serialize;
local path_separator = assert ( package.config:match ( "^([^\n]+)" ) , "package.config not in standard form" ) -- Extract directory seperator from package.config (an undocumented string that comes with lua)
local lfs = require "lfs";
local prosody = prosody;
-local raw_mkdir;
-local fallocate;
-
-if prosody.platform == "posix" then
- raw_mkdir = require "util.pposix".mkdir; -- Doesn't trample on umask
- fallocate = require "util.pposix".fallocate;
-else
- raw_mkdir = lfs.mkdir;
-end
-if not fallocate then -- Fallback
- function fallocate(f, offset, len)
- -- This assumes that current position == offset
- local fake_data = (" "):rep(len);
- local ok, msg = f:write(fake_data);
- if not ok then
- return ok, msg;
- end
- f:seek("set", offset);
- return true;
+local raw_mkdir = lfs.mkdir;
+local function fallocate(f, offset, len)
+ -- This assumes that current position == offset
+ local fake_data = (" "):rep(len);
+ local ok, msg = f:write(fake_data);
+ if not ok then
+ return ok, msg;
end
-end
+ f:seek("set", offset);
+ return true;
+end;
+pcall(function()
+ local pposix = require "util.pposix";
+ raw_mkdir = pposix.mkdir or raw_mkdir; -- Doesn't trample on umask
+ fallocate = pposix.fallocate or fallocate;
+end);
module "datamanager"