diff options
author | Waqas Hussain <waqas20@gmail.com> | 2012-09-12 22:03:57 +0500 |
---|---|---|
committer | Waqas Hussain <waqas20@gmail.com> | 2012-09-12 22:03:57 +0500 |
commit | 543b3a5e807c88050d8cf277eacc9aa0eb46f5d7 (patch) | |
tree | 08a6ec94b0740736361418e0eeed54ccb7486547 /util/datamanager.lua | |
parent | 955f9b6e14b048498925a14a3be97adc025f6c2c (diff) | |
parent | a79c507ade52c12c691a1eb79fbf80f0cba5be77 (diff) | |
download | prosody-543b3a5e807c88050d8cf277eacc9aa0eb46f5d7.tar.gz prosody-543b3a5e807c88050d8cf277eacc9aa0eb46f5d7.zip |
Merge 0.9->trunk
Diffstat (limited to 'util/datamanager.lua')
-rw-r--r-- | util/datamanager.lua | 35 |
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" |