UNSAFE MODULE; IMPORT OSError, File, FileWr, WrClass; IMPORT Unix, OSErrorPosix, FilePosix, Utypes; REVEAL T = FileWr.T BRANDED OBJECT fd: INTEGER; OVERRIDES init := MyInit; END; PROCEDURE OSSupport MyInit (t: T; f: File.T; buffered: BOOLEAN := TRUE) : FileWr.T RAISES {OSError.E} = BEGIN t.fd := f.fd; RETURN FileWr.T.init(t, f, buffered); END MyInit; PROCEDURESync (wr: T) RAISES {OSError.E} = BEGIN IF Unix.fsync (wr.fd) < 0 THEN OSErrorPosix.Raise(); END; END Sync; PROCEDURETruncate (wr: T) RAISES {OSError.E} = BEGIN WrClass.Lock(wr); TRY IF Unix.ftruncate(wr.fd, VAL(wr.cur, Utypes.off_t)) < 0 THEN OSErrorPosix.Raise(); END; FINALLY WrClass.Unlock(wr); END; END Truncate; BEGIN END OSSupport.