# 0.28.0: fs.seek / fs.tell resume a read at a byte offset, and fs.syncDir# makes a rename survive a crash. It writes and removes demo-seek/ here.use fs;
use io;
fs.mkdir("demo-seek");
def f asfs.File initfs.open("demo-seek/log.txt.tmp", "write");
fs.writeString($f, "first line\nsecond line\nthird line\n");
fs.sync($f); # the datafs.close($f);
fs.rename("demo-seek/log.txt.tmp", "demo-seek/log.txt");
fs.syncDir("demo-seek"); # the new namedef r asfs.File initfs.open("demo-seek/log.txt", "read");
io.printf("%s\n", fs.readLine($r));
def mark asintinitfs.tell($r); # start of the next lineio.printf("saved offset %d\n", $mark);
fs.seek($r, 0);
io.printf("%s\n", fs.readLine($r));
fs.seek($r, $mark); # resume where we wereio.printf("%s\n", fs.readLine($r));
fs.close($r);
fs.remove("demo-seek/log.txt");
fs.remove("demo-seek");