]> git.saurik.com Git - apt.git/commitdiff
apt-helper: Use CopyFile() for concatenating the files
authorJulian Andres Klode <jak@debian.org>
Mon, 28 Dec 2015 10:41:04 +0000 (11:41 +0100)
committerJulian Andres Klode <jak@debian.org>
Mon, 28 Dec 2015 10:41:04 +0000 (11:41 +0100)
There's no point in keeping using yet another read-then-write
loop.

Gbp-Dch: ignore

cmdline/apt-helper.cc

index a519f3042be72527ed4e3c0eda8f5dced3b85fc7..5e0b00c46342a1045762723381d5b68ee776ba89 100644 (file)
@@ -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;
 }