mod_scansion_record: Open a related file for header entries
authorKim Alvefur <zash@zash.se>
Sat, 22 Sep 2018 14:36:34 +0200
changeset 9367 62f9127ab493
parent 9366 c4ecaaf66e76
child 9368 acb316319dc0
mod_scansion_record: Open a related file for header entries Since It's tricky to go back and insert data at the beginning of a file, but `cat blah.sch blah.scs` ought to be fine for now.
plugins/mod_scansion_record.lua
--- a/plugins/mod_scansion_record.lua	Sat Sep 22 14:30:10 2018 +0200
+++ b/plugins/mod_scansion_record.lua	Sat Sep 22 14:36:34 2018 +0200
@@ -10,14 +10,20 @@
 
 local record_id = id.medium():lower();
 local record_date = os.date("%Y%b%d"):lower();
+local header_file = dm.getpath(record_id, "scansion", record_date, "sch", true);
 local record_file = dm.getpath(record_id, "scansion", record_date, "scs", true);
 
+local head = io.open(header_file, "w");
 local scan = io.open(record_file, "w");
 
 local function record(string)
 	scan:write(string);
 end
 
+local function record_header(string)
+	head:write(string);
+end
+
 local function record_event(session, event)
 	record(session.scansion_id.." "..event.."\n\n");
 end
@@ -74,4 +80,5 @@
 module:hook_global("server-stopping", function ()
 	module:log("info", "Scansion recording available in %s", record_file);
 	scan:close();
+	head:close()
 end);