Comparison

util/datamanager.lua @ 5069:7b298f8bcbcb

Merge Waqas<>Zash
author Matthew Wild <mwild1@gmail.com>
date Tue, 31 Jul 2012 23:07:02 +0100
parent 5066:4be7093edde9
parent 5065:acfaf771f10e
child 5095:dddbcd62183a
comparison
equal deleted inserted replaced
5068:14d4fc5859b9 5069:7b298f8bcbcb
169 if f then f:close(); end 169 if f then f:close(); end
170 os_remove(scratch); 170 os_remove(scratch);
171 return nil, msg; 171 return nil, msg;
172 end 172 end
173 173
174 if prosody.platform ~= "posix" then
175 -- os.rename does not overwrite existing files on Windows
176 -- TODO We could use Transactional NTFS on Vista and above
177 function atomic_store(filename, data)
178 local f, err = io_open(filename, "w");
179 if not f then return f, err; end
180 local ok, msg = f:write(data);
181 if not ok then f:close(); return ok, msg; end
182 return f:close();
183 end
184 end
185
174 function store(username, host, datastore, data) 186 function store(username, host, datastore, data)
175 if not data then 187 if not data then
176 data = {}; 188 data = {};
177 end 189 end
178 190