From a80524d573d3f07fa8ccdd95ff404d793704df0a Mon Sep 17 00:00:00 2001 From: Jamie Reece Wilson Date: Fri, 15 Sep 2023 15:53:20 +0100 Subject: [PATCH] [-] AuProcesses::EStandardHandle --- Include/Aurora/IO/EStandardStream.hpp | 5 +++++ Include/Aurora/Processes/EStandardHandle.hpp | 13 +++---------- Source/IO/AuIOHandle.Unix.cpp | 1 - Source/Processes/AuProcess.NT.cpp | 12 +++++++++--- Source/Processes/AuProcess.Unix.cpp | 14 +++++++++++++- 5 files changed, 30 insertions(+), 15 deletions(-) diff --git a/Include/Aurora/IO/EStandardStream.hpp b/Include/Aurora/IO/EStandardStream.hpp index 690ad26a..250716ee 100644 --- a/Include/Aurora/IO/EStandardStream.hpp +++ b/Include/Aurora/IO/EStandardStream.hpp @@ -10,8 +10,13 @@ namespace Aurora::IO { AUE_DEFINE_VA(EStandardStream, + // Process Input Stream eInputStream, + + // Process Output Stream eOutputStream, + + // Process Error Stream eErrorStream ); } \ No newline at end of file diff --git a/Include/Aurora/Processes/EStandardHandle.hpp b/Include/Aurora/Processes/EStandardHandle.hpp index 1104a0dd..12470519 100644 --- a/Include/Aurora/Processes/EStandardHandle.hpp +++ b/Include/Aurora/Processes/EStandardHandle.hpp @@ -7,17 +7,10 @@ ***/ #pragma once +#include + namespace Aurora::Processes { - AUE_DEFINE(EStandardHandle, - ( - // Process Input Stream - eStdIn, + using EStandardHandle = Aurora::IO::EStandardStream; - // Process Output Stream - eStdOut, - - // Process Error Stream - eStdError - )); } \ No newline at end of file diff --git a/Source/IO/AuIOHandle.Unix.cpp b/Source/IO/AuIOHandle.Unix.cpp index 4466b209..4e999074 100644 --- a/Source/IO/AuIOHandle.Unix.cpp +++ b/Source/IO/AuIOHandle.Unix.cpp @@ -52,7 +52,6 @@ namespace Aurora::IO return Aurora::IO::DupHandle(uOSHandle, bWriteAccess, false); } - AuUInt64 AFileHandle::DupHandle(AuUInt64 uOSHandle, bool bWriteAccess, bool bShareAccess) { return Aurora::IO::DupHandle(uOSHandle, bWriteAccess, bShareAccess); diff --git a/Source/Processes/AuProcess.NT.cpp b/Source/Processes/AuProcess.NT.cpp index 445847e6..30c3008f 100644 --- a/Source/Processes/AuProcess.NT.cpp +++ b/Source/Processes/AuProcess.NT.cpp @@ -171,13 +171,19 @@ namespace Aurora::Processes { DWORD size = destination.length; - if (!EStandardHandleIsValid(stream) || (stream == EStandardHandle::eStdIn)) + if (!IO::EStandardStreamIsValid(stream) || (stream == EStandardHandle::eInputStream)) { SysPushErrorArg("Invalid Stream"); - return {}; + return false; } - auto handle = stream == EStandardHandle::eStdError ? this->pipeStdErrRead_ : this->pipeStdOutRead_; + if (!destination) + { + SysPushErrorArg(); + return false; + } + + auto handle = stream == EStandardHandle::eErrorStream ? this->pipeStdErrRead_ : this->pipeStdOutRead_; if (handle == INVALID_HANDLE_VALUE) { return false; diff --git a/Source/Processes/AuProcess.Unix.cpp b/Source/Processes/AuProcess.Unix.cpp index e7742df7..1ff30dbc 100644 --- a/Source/Processes/AuProcess.Unix.cpp +++ b/Source/Processes/AuProcess.Unix.cpp @@ -197,7 +197,19 @@ namespace Aurora::Processes bool ProcessImpl::Read(EStandardHandle stream, const AuMemoryViewStreamWrite &destination, bool nonblock) { - auto handle = stream == EStandardHandle::eStdError ? this->pipeStdErr_[0] : this->pipeStdOut_[0]; + if (!IO::EStandardStreamIsValid(stream) || (stream == EStandardHandle::eInputStream)) + { + SysPushErrorArg("Invalid Stream"); + return false; + } + + if (!destination) + { + SysPushErrorArg(); + return false; + } + + auto handle = stream == EStandardHandle::eErrorStream ? this->pipeStdErr_[0] : this->pipeStdOut_[0]; if (handle < 0) { SysPushErrorUninitialized();