2 % (c) The GRASP/AQUA Project, Glasgow University, 1994
4 \subsection[flushFile.lc]{hFlush Runtime Support}
6 Empty contents of output buffers.
17 IOFileObject* fo = (IOFileObject*)ptr;
20 if ( (fo->flags & FILEOBJ_FLUSH) && !FILEOBJ_BUFFER_EMPTY(fo) ) {
21 rc = writeBuffer(ptr,fo->bufWPtr - fo->bufRPtr);
31 IOFileObject* fo = (IOFileObject*)ptr;
34 /* If the file object is writeable, or if its
35 RW and the last operation on it was a write,
38 if ( (!FILEOBJ_READABLE(fo) && FILEOBJ_WRITEABLE(fo)) || (FILEOBJ_RW(fo) && FILEOBJ_JUST_WRITTEN(fo)) ) {
43 /* Reset read & write pointer for input buffers */
44 if ( (fo->flags & FILEOBJ_READ) ) {
52 For RW file objects, flushing input buffers doesn't just involve
53 resetting the read & write pointers, we also have to change the
54 underlying file position to point to the effective read position.
56 (Sigh, I now understand the real reason for why stdio opted for
57 the solution of leaving this to the programmer!)
63 IOFileObject* fo = (IOFileObject*)ptr;
66 delta = fo->bufWPtr - fo->bufRPtr;
69 while ( lseek(fo->fd, -delta, SEEK_CUR) == -1) {