aboutsummaryrefslogtreecommitdiffstats
path: root/src/fs/io/BufferedOutputStream.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2015-03-22 17:01:33 +0100
committerMax Kellermann <max@duempel.org>2015-03-23 22:03:25 +0100
commitcd352716981310c37ae59d9b09f353b621318a3b (patch)
tree1212e74cc9263e7f9d24f5f67ae2c41823f8e3af /src/fs/io/BufferedOutputStream.cxx
parent7b575f61d0f5c34267fcfd60229d25edbcbe33da (diff)
downloadmpd-cd352716981310c37ae59d9b09f353b621318a3b.tar.gz
mpd-cd352716981310c37ae59d9b09f353b621318a3b.tar.xz
mpd-cd352716981310c37ae59d9b09f353b621318a3b.zip
fs/io/BufferedOutputStream: add code comments
Diffstat (limited to 'src/fs/io/BufferedOutputStream.cxx')
-rw-r--r--src/fs/io/BufferedOutputStream.cxx5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/fs/io/BufferedOutputStream.cxx b/src/fs/io/BufferedOutputStream.cxx
index 7d3cd3815..2268eb50c 100644
--- a/src/fs/io/BufferedOutputStream.cxx
+++ b/src/fs/io/BufferedOutputStream.cxx
@@ -41,17 +41,22 @@ bool
BufferedOutputStream::Write(const void *data, size_t size)
{
if (gcc_unlikely(last_error.IsDefined()))
+ /* the stream has already failed */
return false;
+ /* try to append to the current buffer */
if (AppendToBuffer(data, size))
return true;
+ /* not enough room in the buffer - flush it */
if (!Flush())
return false;
+ /* see if there's now enough room */
if (AppendToBuffer(data, size))
return true;
+ /* too large for the buffer: direct write */
return os.Write(data, size, last_error);
}