Software /
code /
prosody
Comparison
util/datamanager.lua @ 7001:2743759ca1b5
util.datamanager: Return extra location info
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 11 Dec 2015 20:31:19 +0100 |
parent | 7000:2b57f77985a3 |
child | 7002:9ab0d5e69c41 |
comparison
equal
deleted
inserted
replaced
7000:2b57f77985a3 | 7001:2743759ca1b5 |
---|---|
218 local f, msg = io_open(filename, "r+"); | 218 local f, msg = io_open(filename, "r+"); |
219 if not f then | 219 if not f then |
220 -- File did probably not exist, let's create it | 220 -- File did probably not exist, let's create it |
221 f, msg = io_open(filename, "w"); | 221 f, msg = io_open(filename, "w"); |
222 if not f then | 222 if not f then |
223 return nil, msg; | 223 return nil, msg, "open"; |
224 end | 224 end |
225 end | 225 end |
226 | 226 |
227 local pos = f:seek("end"); | 227 local pos = f:seek("end"); |
228 ok, msg = fallocate(f, pos, #data); | 228 ok, msg = fallocate(f, pos, #data); |
237 end | 237 end |
238 | 238 |
239 ok, msg = f:write(data); | 239 ok, msg = f:write(data); |
240 if not ok then | 240 if not ok then |
241 f:close(); | 241 f:close(); |
242 return ok, msg, "write"; | |
243 end | |
244 | |
245 ok, msg = f:close(); | |
246 if not ok then | |
242 return ok, msg; | 247 return ok, msg; |
243 end | 248 end |
244 | 249 |
245 ok, msg = f:close(); | 250 return true, pos; |
246 if not ok then | |
247 return ok, msg; | |
248 end | |
249 | |
250 return true; | |
251 end | 251 end |
252 | 252 |
253 local function list_append(username, host, datastore, data) | 253 local function list_append(username, host, datastore, data) |
254 if not data then return; end | 254 if not data then return; end |
255 if callback(username, host, datastore) == false then return true; end | 255 if callback(username, host, datastore) == false then return true; end |