MCPcopy Create free account
hub / github.com/arun11299/cpp-subprocess / file_from_handle

Function file_from_handle

cpp-subprocess/subprocess.hpp:386–416  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

384 }
385
386 inline FILE *file_from_handle(HANDLE h, const char *mode)
387 {
388 int md;
389 if (!mode) {
390 throw OSError("invalid_mode", 0);
391 }
392
393 if (mode[0] == 'w') {
394 md = _O_WRONLY;
395 }
396 else if (mode[0] == 'r') {
397 md = _O_RDONLY;
398 }
399 else {
400 throw OSError("file_from_handle", 0);
401 }
402
403 int os_fhandle = _open_osfhandle((intptr_t)h, md);
404 if (os_fhandle == -1) {
405 CloseHandle(h);
406 throw OSError("_open_osfhandle", 0);
407 }
408
409 FILE *fp = _fdopen(os_fhandle, mode);
410 if (fp == 0) {
411 subprocess_close(os_fhandle);
412 throw OSError("_fdopen", 0);
413 }
414
415 return fp;
416 }
417
418 inline void configure_pipe(HANDLE* read_handle, HANDLE* write_handle, HANDLE* child_handle)
419 {

Callers 1

setup_comm_channelsMethod · 0.85

Calls 1

OSErrorClass · 0.85

Tested by

no test coverage detected