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

Function _hx_std_process_stdin_write

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

process_stdin_write : 'process -> buf:string -> pos:int -> len:int -> int Write up to [len] bytes from [buf] starting at [pos] to the process stdin. Returns the number of bytes writen this way. Raise an exception if this process stdin is closed. **/

Source from the content-addressed store, hash-verified

407 </doc>
408**/
409int _hx_std_process_stdin_write( Dynamic handle, Array<unsigned char> buf, int pos, int len )
410{
411 if( pos < 0 || len < 0 || pos + len > buf->length )
412 return 0;
413 vprocess *p = getProcess(handle);
414
415 unsigned char *src = &buf[0];
416
417
418 hx::EnterGCFreeZone();
419 #ifdef NEKO_WINDOWS
420 DWORD nbytes =0;
421 if( !WriteFile(p->iwrite,src+pos,len,&nbytes,0) )
422 nbytes = 0;
423 #else
424 int nbytes = write(p->iwrite,src+pos,len);
425 if( nbytes == -1 )
426 nbytes = 0;
427 #endif
428
429 hx::ExitGCFreeZone();
430 return nbytes;
431}
432
433/**
434 process_stdin_close : 'process -> void

Callers

nothing calls this directly

Calls 3

getProcessFunction · 0.85
EnterGCFreeZoneFunction · 0.85
ExitGCFreeZoneFunction · 0.85

Tested by

no test coverage detected