tesses-webserver-cpp/wwwroot/init.twss

39 lines
686 B
Plaintext

<!--tws
lock();
todos = load();
unlock();
func load()
{
var f = fopen("todos.json","rb");
if(f)
{
var len = flength(f);
ba = bytearray(len);
fread(ba,0,len, f);
fclose(f);
var txt = ba.toString();
free(ba);
return JSON_decode(txt);
}
else
{
return list();
}
}
func save()
{
var s = JSON_encode(todos);
var ba = bytearray(s);
var f = fopen("todos.json","wb");
fwrite(ba,0,ba.count(),f);
flength(f);
fclose(f);
free(ba);
}
-->