aboutsummaryrefslogtreecommitdiffstats
path: root/src/fs/io/BufferedOutputStream.cxx
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/fs/io/BufferedOutputStream.cxx7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/fs/io/BufferedOutputStream.cxx b/src/fs/io/BufferedOutputStream.cxx
index 088a3e279..2268eb50c 100644
--- a/src/fs/io/BufferedOutputStream.cxx
+++ b/src/fs/io/BufferedOutputStream.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2014 The Music Player Daemon Project
+ * Copyright (C) 2003-2015 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -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);
}