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 **/
| 346 | </doc> |
| 347 | **/ |
| 348 | int _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 | /** |
nothing calls this directly
no test coverage detected