MCPcopy Create free account
hub / github.com/Kitware/CMake / writeDataToStreamPipe

Function writeDataToStreamPipe

Tests/CMakeLib/testUVStreambuf.cxx:21–71  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19#define TEST_STR TEST_STR_LINE_1 "\n" TEST_STR_LINE_2 "\n" TEST_STR_LINE_3
20
21static bool writeDataToStreamPipe(uv_loop_t& loop, cm::uv_pipe_ptr& inputPipe,
22 char* outputData,
23 unsigned int outputDataLength,
24 char const* /* unused */)
25{
26 int err;
27
28 // Create the pipe
29 int pipeHandles[2];
30 if (cmGetPipes(pipeHandles) < 0) {
31 std::cout << "Could not open pipe" << std::endl;
32 return false;
33 }
34
35 cm::uv_pipe_ptr outputPipe;
36 inputPipe.init(loop, 0);
37 outputPipe.init(loop, 0);
38 uv_pipe_open(inputPipe, pipeHandles[0]);
39 uv_pipe_open(outputPipe, pipeHandles[1]);
40
41 // Write data for reading
42 uv_write_t writeReq;
43 struct WriteCallbackData
44 {
45 bool Finished = false;
46 int Status;
47 } writeData;
48 writeReq.data = &writeData;
49 uv_buf_t outputBuf;
50 outputBuf.base = outputData;
51 outputBuf.len = outputDataLength;
52 if ((err = uv_write(&writeReq, outputPipe, &outputBuf, 1,
53 [](uv_write_t* req, int status) {
54 auto data = static_cast<WriteCallbackData*>(req->data);
55 data->Finished = true;
56 data->Status = status;
57 })) < 0) {
58 std::cout << "Could not write to pipe: " << uv_strerror(err) << std::endl;
59 return false;
60 }
61 while (!writeData.Finished) {
62 uv_run(&loop, UV_RUN_ONCE);
63 }
64 if (writeData.Status < 0) {
65 std::cout << "Status is " << uv_strerror(writeData.Status)
66 << ", should be 0" << std::endl;
67 return false;
68 }
69
70 return true;
71}
72
73static bool writeDataToStreamProcess(uv_loop_t& loop,
74 cm::uv_pipe_ptr& inputPipe,

Callers

nothing calls this directly

Calls 6

cmGetPipesFunction · 0.85
uv_strerrorFunction · 0.85
uv_pipe_openFunction · 0.50
uv_writeFunction · 0.50
uv_runFunction · 0.50
initMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…