MCPcopy Create free account
hub / github.com/ROCm/AMDMIGraphX / read

Method read

src/process.cpp:397–435  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

395}
396
397void process::read(const writer& output) const
398{
399#ifdef _WIN32
400 // clang-format off
401 constexpr std::string_view filename = "stdout";
402 auto tmp = tmp_dir{};
403 HANDLE handle = CreateFile((tmp.path / filename).string().c_str(),
404 GENERIC_READ | GENERIC_WRITE,
405 0,
406 nullptr,
407 CREATE_ALWAYS,
408 FILE_ATTRIBUTE_NORMAL,
409 nullptr);
410 impl->check_exec(impl->command, impl->cwd.string(), impl->args, impl->envs,
411 handle == nullptr or handle == INVALID_HANDLE_VALUE ?
412 GetStdHandle(STD_OUTPUT_HANDLE) : handle);
413 CloseHandle(handle);
414 handle = CreateFile((tmp.path / filename).string().c_str(),
415 GENERIC_READ | GENERIC_WRITE,
416 0,
417 nullptr,
418 OPEN_EXISTING,
419 FILE_ATTRIBUTE_NORMAL,
420 nullptr);
421 if(handle == nullptr or handle == INVALID_HANDLE_VALUE)
422 MIGRAPHX_THROW("Unable to open file: " + (tmp.path / filename));
423 auto size = GetFileSize(handle, nullptr);
424 std::string result(size, '\0');
425 if(ReadFile(handle, result.data(), size, nullptr, nullptr) == FALSE)
426 MIGRAPHX_THROW("Failed reading file: " + (tmp.path / filename));
427 CloseHandle(handle);
428 // clang-format on
429#else
430 std::stringstream ss;
431 impl->check_exec(impl->get_command(), redirect_to(ss));
432 auto result = ss.str();
433#endif
434 output(result.data(), result.size());
435}
436
437void process::exec()
438{

Callers 1

execFunction · 0.45

Calls 6

redirect_toFunction · 0.85
check_execMethod · 0.80
get_commandMethod · 0.80
dataMethod · 0.45
strMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected