MCPcopy Create free account
hub / github.com/MusicPlayerDaemon/MPD / Copy

Function Copy

test/WriteFile.cxx:16–33  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14#include <stdio.h>
15
16static bool
17Copy(OutputStream &dest, int src)
18{
19 while (true) {
20 std::byte buffer[8192];
21 ssize_t nbytes = read(src, buffer, sizeof(buffer));
22 if (nbytes < 0) {
23 fprintf(stderr, "Failed to read from stdin: %s\n",
24 strerror(errno));
25 return false;
26 }
27
28 if (nbytes == 0)
29 return true;
30
31 dest.Write(std::span{buffer}.first(nbytes));
32 }
33}
34
35int
36main(int argc, char **argv)

Callers 1

mainFunction · 0.70

Calls 1

WriteMethod · 0.45

Tested by

no test coverage detected