2 * (c) The GRASP/AQUA Project, Glasgow University, 1994-1998
4 * $Id: flushFile.c,v 1.3 1998/12/02 13:27:32 simonm Exp $
6 * hFlush Runtime Support
16 IOFileObject* fo = (IOFileObject*)ptr;
19 if ( (fo->flags & FILEOBJ_FLUSH) && !FILEOBJ_BUFFER_EMPTY(fo) ) {
20 rc = writeBuffer(ptr,fo->bufWPtr - fo->bufRPtr);
30 IOFileObject* fo = (IOFileObject*)ptr;
33 /* If the file object is writeable, or if its
34 RW and the last operation on it was a write,
37 if ( (!FILEOBJ_READABLE(fo) && FILEOBJ_WRITEABLE(fo)) || (FILEOBJ_RW(fo) && FILEOBJ_JUST_WRITTEN(fo)) ) {
42 /* Reset read & write pointer for input buffers */
43 if ( (fo->flags & FILEOBJ_READ) ) {
51 For RW file objects, flushing input buffers doesn't just involve
52 resetting the read & write pointers, we also have to change the
53 underlying file position to point to the effective read position.
55 (Sigh, I now understand the real reason for why stdio opted for
56 the solution of leaving this to the programmer!)
62 IOFileObject* fo = (IOFileObject*)ptr;
65 delta = fo->bufWPtr - fo->bufRPtr;
68 while ( lseek(fo->fd, -delta, SEEK_CUR) == -1) {