From 1510dd113d86a62405cb61b370fbd716450f9d58 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Fri, 11 Dec 2015 20:29:55 +0100 Subject: util.datamanager: Add some comments about the append function --- util/datamanager.lua | 3 +++ 1 file changed, 3 insertions(+) (limited to 'util/datamanager.lua') diff --git a/util/datamanager.lua b/util/datamanager.lua index ce4c5b5a..510c0161 100644 --- a/util/datamanager.lua +++ b/util/datamanager.lua @@ -209,17 +209,20 @@ local function store(username, host, datastore, data) return true; end +-- Append a blob of data to a file local function append(username, host, datastore, ext, data) local filename = getpath(username, host, datastore, ext, true); local ok; local f, msg = io_open(filename, "r+"); if not f then + -- File did probably not exist, let's create it f, msg = io_open(filename, "w"); if not f then return nil, msg; end end + local pos = f:seek("end"); ok, msg = fallocate(f, pos, #data); if not ok then -- cgit v1.2.3