diff options
author | Thomas Guillem <thomas@gllm.fr> | 2015-06-05 16:27:10 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2015-06-22 08:51:14 +0200 |
commit | 6e2d7445c50e30090e468f7c76fb95ff0c219183 (patch) | |
tree | 5c6c938d12ac53958c961f2526a659e3b0a208f3 /src/input/InputStream.hxx | |
parent | 90e7ace980fcfe4f894cd8e882fbfd2efba0b57d (diff) | |
download | mpd-6e2d7445c50e30090e468f7c76fb95ff0c219183.tar.gz mpd-6e2d7445c50e30090e468f7c76fb95ff0c219183.tar.xz mpd-6e2d7445c50e30090e468f7c76fb95ff0c219183.zip |
InputStream: add ReadFull method
Convenient method that behave differently than Read, and that will be used by
tag scanners.
This method will return in case of error, if the whole data is read or is EOF
is reached.
Diffstat (limited to '')
-rw-r--r-- | src/input/InputStream.hxx | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/input/InputStream.hxx b/src/input/InputStream.hxx index 84b4f3fae..3733b20a5 100644 --- a/src/input/InputStream.hxx +++ b/src/input/InputStream.hxx @@ -363,6 +363,25 @@ public: */ gcc_nonnull_all size_t LockRead(void *ptr, size_t size, Error &error); + + /** + * Reads the whole data from the stream into the caller-supplied buffer. + * + * The caller must lock the mutex. + * + * @param ptr the buffer to read into + * @param size the number of bytes to read + * @return true if the whole data was read, false otherwise. + */ + gcc_nonnull_all + bool ReadFull(void *ptr, size_t size, Error &error); + + /** + * Wrapper for ReadFull() which locks and unlocks the mutex; + * the caller must not be holding it already. + */ + gcc_nonnull_all + bool LockReadFull(void *ptr, size_t size, Error &error); }; #endif |