summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2015-12-28 11:41:04 +0100
committerJulian Andres Klode <jak@debian.org>2015-12-28 11:41:04 +0100
commitff2717e8c6a7633bbd38be95b2d30615802b6679 (patch)
tree995f8c1309e79d27d94781d1bfff3059cabd1c4e
parent80f06991967d4daccb1c0c1147a6e16291ebb027 (diff)
apt-helper: Use CopyFile() for concatenating the files
There's no point in keeping using yet another read-then-write loop. Gbp-Dch: ignore
-rw-r--r--cmdline/apt-helper.cc12
1 files changed, 2 insertions, 10 deletions
diff --git a/cmdline/apt-helper.cc b/cmdline/apt-helper.cc
index a519f3042..5e0b00c46 100644
--- a/cmdline/apt-helper.cc
+++ b/cmdline/apt-helper.cc
@@ -111,8 +111,6 @@ static bool DoCatFile(CommandLine &CmdL) /*{{{*/
{
FileFd fd;
FileFd out;
- char buf[4096];
- unsigned long long read;
if (out.OpenDescriptor(STDOUT_FILENO, FileFd::WriteOnly) == false)
return false;
@@ -127,14 +125,8 @@ static bool DoCatFile(CommandLine &CmdL) /*{{{*/
if (fd.Open(name, FileFd::ReadOnly, FileFd::Extension) == false)
return false;
- for (;;) {
- if (fd.Read(buf, sizeof(buf), &read) == false)
- return false;
- if (read == 0)
- break;
- if (out.Write(buf, read) == false)
- return false;
- }
+ if (CopyFile(fd, out) == false)
+ return false;
}
return true;
}