// a persistent list that only grows (or is clear()ed)
// Note: don't put in static initializer (programID not set yet)
static class PersistentLog extends AbstractList {
new L l;
File file;
PersistentLog(S fileName) {
this(getProgramFile(fileName));
}
PersistentLog(S progID, S fileName) {
this(getProgramFile(progID, fileName));
}
*(File *file) {
for (S s : scanLog(file)) pcall {
l.add((A) unstructure(s));
}
}
public synchronized int size() {
ret l.size();
}
public synchronized A get(int i) {
ret l.get(i);
}
public synchronized bool add(A a) {
l.add(a);
logQuoted(file, structure(a));
ret true;
}
S fileContents() {
ret loadTextFile(file);
}
public synchronized void clear() {
l.clear();
file.delete();
}
}