[FL-2693] RW buffered streams (#1523)

* Add write methods for stream cache
* Fix logical error
* Implement write cache for buffered file streams
* Minor code refactoring
* Less ugly code
* Better read() implementation
* Intermediate implementation
* Fix logical error
* Code cleanup
* Update FFF comments
* Fix logical error
* Github: rsync with delete

Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
Georgii Surkov
2022-08-03 19:43:14 +03:00
committed by GitHub
parent 6499597586
commit 135fbd294b
6 changed files with 156 additions and 35 deletions

View File

@@ -55,6 +55,14 @@ size_t stream_cache_pos(StreamCache* cache);
*/
size_t stream_cache_fill(StreamCache* cache, Stream* stream);
/**
* Write as much cached data as possible to a stream.
* @param cache Pointer to a StreamCache instance
* @param stream Pointer to a Stream instance
* @return True on success, False on failure.
*/
bool stream_cache_flush(StreamCache* cache, Stream* stream);
/**
* Read cached data and advance the internal cursor.
* @param cache Pointer to a StreamCache instance.
@@ -64,6 +72,15 @@ size_t stream_cache_fill(StreamCache* cache, Stream* stream);
*/
size_t stream_cache_read(StreamCache* cache, uint8_t* data, size_t size);
/**
* Write to cached data and advance the internal cursor.
* @param cache Pointer to a StreamCache instance.
* @param data Pointer to a data buffer.
* @param size Maximum size in bytes to write to the cache.
* @return Actual size that was written.
*/
size_t stream_cache_write(StreamCache* cache, const uint8_t* data, size_t size);
/**
* Move the internal cursor relatively to its current position.
* @param cache Pointer to a StreamCache instance.