3 /* _PDCLIB_flushbuffer( struct _PDCLIB_file_t * )
5 This file is part of the Public Domain C Library (PDCLib).
6 Permission is granted to use, modify, and / or redistribute at will.
9 /* This is a stub implementation of _PDCLIB_flushbuffer
16 #include <_PDCLIB_glue.h>
20 void _PDCLIB_w32errno( void );
22 int _PDCLIB_flushbuffer( struct _PDCLIB_file_t * stream )
24 if ( ! ( stream->status & _PDCLIB_FBIN ) )
26 /* TODO: Text stream conversion here */
32 while(written != stream->bufidx) {
34 DWORD toWrite = stream->bufidx - written;
35 BOOL res = WriteFile( stream->handle, stream->buffer + written,
36 toWrite, &justWrote, NULL);
38 stream->pos.offset += justWrote;
41 stream->status |=_PDCLIB_ERRORFLAG;
42 stream->bufidx -= written;
43 memmove( stream->buffer, stream->buffer + written, stream->bufidx );
57 #include <_PDCLIB_test.h>
61 /* Testing covered by ftell.c */