Add convenience functions to get process IOStreams

This commit is contained in:
ritalat
2024-09-14 03:55:53 +03:00
committed by Sam Lantinga
parent 7ff015ceae
commit f6f49de134
6 changed files with 83 additions and 5 deletions

View File

@@ -153,6 +153,38 @@ done:
return result;
}
SDL_IOStream *SDL_GetProcessOutputStream(SDL_Process *process)
{
if (!process) {
SDL_InvalidParamError("process");
return NULL;
}
SDL_IOStream *io = (SDL_IOStream *)SDL_GetPointerProperty(process->props, SDL_PROP_PROCESS_STDOUT_POINTER, NULL);
if (!io) {
SDL_SetError("Process not created with I/O enabled");
return NULL;
}
return io;
}
SDL_IOStream *SDL_GetProcessInputStream(SDL_Process *process)
{
if (!process) {
SDL_InvalidParamError("process");
return NULL;
}
SDL_IOStream *io = (SDL_IOStream *)SDL_GetPointerProperty(process->props, SDL_PROP_PROCESS_STDIN_POINTER, NULL);
if (!io) {
SDL_SetError("Process not created with I/O enabled");
return NULL;
}
return io;
}
SDL_bool SDL_KillProcess(SDL_Process *process, SDL_bool force)
{
if (!process) {