Comparison

util/datamanager.lua @ 6996:644b1bddc676

util.datamanager: No shadowing of variable [luacheck]
author Kim Alvefur <zash@zash.se>
date Fri, 11 Dec 2015 20:22:54 +0100
parent 6995:807b0b2ee545
child 6997:0ab228bc21c6
comparison
equal deleted inserted replaced
6995:807b0b2ee545 6996:644b1bddc676
209 return true; 209 return true;
210 end 210 end
211 211
212 local function append(username, host, datastore, ext, data) 212 local function append(username, host, datastore, ext, data)
213 local filename = getpath(username, host, datastore, ext, true); 213 local filename = getpath(username, host, datastore, ext, true);
214
215 local ok;
214 local f, msg = io_open(filename, "r+"); 216 local f, msg = io_open(filename, "r+");
215 if not f then 217 if not f then
216 f, msg = io_open(filename, "w"); 218 f, msg = io_open(filename, "w");
217 if not f then 219 if not f then
218 return nil, msg; 220 return nil, msg;
219 end 221 end
220 end 222 end
221 local pos = f:seek("end"); 223 local pos = f:seek("end");
222 local ok, msg = fallocate(f, pos, #data); 224 ok, msg = fallocate(f, pos, #data);
223 f:seek("set", pos); 225 f:seek("set", pos);
224 if ok then 226 if ok then
225 f:write(data); 227 f:write(data);
226 else 228 else
227 return ok, msg; 229 return ok, msg;