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 int _PDCLIB_flushbuffer( struct _PDCLIB_file_t * stream )
22 if ( ! ( stream->status & _PDCLIB_FBIN ) )
24 /* TODO: Text stream conversion here */
30 while(written != stream->bufidx) {
32 DWORD toWrite = stream->bufidx - written;
33 BOOL res = WriteFile( stream->handle, stream->buffer + written,
34 toWrite, &justWrote, NULL);
36 stream->pos.offset += justWrote;
39 stream->status |=_PDCLIB_ERRORFLAG;
40 stream->bufidx -= written;
41 memmove( stream->buffer, stream->buffer + written, stream->bufidx );
55 #include <_PDCLIB_test.h>
59 /* Testing covered by ftell.c */