|
CX Framework
Cross-platform C utility framework
|
Functions | |
| bool | _sbufFileOut (StreamBuffer *sb, File *file, bool close) |
| bool | _sbufFileCRegisterPush (StreamBuffer *sb, File *file, bool close) |
Functions for using files as stream buffer data sinks.
| bool _sbufFileCRegisterPush | ( | StreamBuffer * | sb, |
| File * | file, | ||
| bool | close | ||
| ) |
bool sbufFileCRegisterPush(StreamBuffer *sb, File *file, bool close)
Registers a file as a consumer with the stream buffer in push mode.
In push mode, data is automatically written to the file as it becomes available from the producer. Use this instead of sbufFileOut() when you need the producer and consumer to operate asynchronously.
The registration holds its own reference to the file until the consumer slot is handed back, so the caller may release its own at any time after this returns.
| sb | The stream buffer |
| file | File to write to. With close set, the caller's reference is handed over with it and the handle must not be used again |
| close | If true, the file is closed when the consumer finishes |
| bool _sbufFileOut | ( | StreamBuffer * | sb, |
| File * | file, | ||
| bool | close | ||
| ) |
bool sbufFileOut(StreamBuffer *sb, File *file, bool close)
Consumes all available data from the buffer and writes it to a file.
Reads data from the stream buffer until the producer finishes (EOF) and writes it to the file in chunks.
| sb | The stream buffer |
| file | File to write to (optionally closed based on close parameter) |
| close | If true, the file is closed after writing |
Example: