There's no point in keeping using yet another read-then-write
loop.
Gbp-Dch: ignore
{
FileFd fd;
FileFd out;
- char buf[4096];
- unsigned long long read;
if (out.OpenDescriptor(STDOUT_FILENO, FileFd::WriteOnly) == false)
return false;
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;
}