1 /* _PDCLIB_flushbuffer( struct _PDCLIB_file_t * )
\r
3 This file is part of the Public Domain C Library (PDCLib).
\r
4 Permission is granted to use, modify, and / or redistribute at will.
\r
11 #include <_PDCLIB_glue.h>
\r
12 #include <_PDCLIB_io.h>
\r
14 int _PDCLIB_flushbuffer( FILE * stream )
\r
16 if ( ! ( stream->status & _PDCLIB_FBIN ) )
\r
18 /* TODO: Text stream conversion here */
\r
24 while(written != stream->bufidx) {
\r
26 size_t toWrite = stream->bufidx - written;
\r
27 bool res = stream->ops->write( stream->handle, stream->buffer + written,
\r
28 toWrite, &justWrote);
\r
29 written += justWrote;
\r
30 stream->pos.offset += justWrote;
\r
33 stream->status |=_PDCLIB_ERRORFLAG;
\r
34 stream->bufidx -= written;
\r
35 memmove( stream->buffer, stream->buffer + written, stream->bufidx );
\r
48 #include <_PDCLIB_test.h>
\r
52 /* Testing covered by ftell.c */
\r
53 return TEST_RESULTS;
\r