aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-04-07 21:24:26 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-04-07 21:24:26 +0100
commit668476062266b62098dbd42f2cfa1fc3afdefdc6 (patch)
tree581b5d4cc77dc2e3e7c891979516895f46332532
parent88fdb40ab45ab6ab2636b385ce0bf5ac42c86f4a (diff)
downloadpaludis-668476062266b62098dbd42f2cfa1fc3afdefdc6.tar.gz
paludis-668476062266b62098dbd42f2cfa1fc3afdefdc6.tar.xz
No need to use icky C things
-rw-r--r--paludis/util/system.cc16
1 files changed, 4 insertions, 12 deletions
diff --git a/paludis/util/system.cc b/paludis/util/system.cc
index ca9ff8e..3898955 100644
--- a/paludis/util/system.cc
+++ b/paludis/util/system.cc
@@ -1075,18 +1075,10 @@ paludis::become_command(const Command & cmd)
/* Feed in any input things */
if (cmd.input_stream())
{
- while (true)
- {
- char c;
- if (cmd.input_stream()->get(c).good())
- {
- int w(write(input_stream->write_fd(), &c, 1));
- if (w != 1)
- throw RunCommandError("write failed: " + stringify(strerror(errno)));
- }
- else
- break;
- }
+ SafeOFStream output_stream(input_stream->write_fd());
+ std::copy((std::istreambuf_iterator<char>(*cmd.input_stream())),
+ std::istreambuf_iterator<char>(),
+ std::ostreambuf_iterator<char>(output_stream));
if (0 != close(input_stream->write_fd()))
throw RunCommandError("close failed: " + stringify(strerror(errno)));