MCPcopy Create free account
hub / github.com/HaxeFoundation/hxcpp / _hx_std_process_stdout_read

Function _hx_std_process_stdout_read

src/hx/libs/std/Process.cpp:348–368  ·  view source on GitHub ↗

process_stdout_read : 'process -> buf:string -> pos:int -> len:int -> int Read up to [len] bytes in [buf] starting at [pos] from the process stdout. Returns the number of bytes readed this way. Raise an exception if this process stdout is closed and no more data is available for reading. For hxcpp, the input buffer is in bytes, not characters **/

Source from the content-addressed store, hash-verified

346 </doc>
347**/
348int _hx_std_process_stdout_read( Dynamic handle, Array<unsigned char> buf, int pos, int len )
349{
350 if( pos < 0 || len < 0 || pos + len > buf->length )
351 return 0;
352 vprocess *p = getProcess(handle);
353
354 unsigned char *dest = &buf[0];
355 hx::EnterGCFreeZone();
356 #ifdef NEKO_WINDOWS
357 DWORD nbytes = 0;
358 if( !ReadFile(p->oread,dest+pos,len,&nbytes,0) )
359 nbytes = 0;
360 #else
361 int nbytes = read(p->oread,dest + pos,len);
362 if( nbytes <= 0 )
363 nbytes = 0;
364 #endif
365
366 hx::ExitGCFreeZone();
367 return nbytes;
368}
369
370
371/**

Callers

nothing calls this directly

Calls 3

getProcessFunction · 0.85
EnterGCFreeZoneFunction · 0.85
ExitGCFreeZoneFunction · 0.85

Tested by

no test coverage detected