1*35238bceSAndroid Build Coastguard Worker /*------------------------------------------------------------------------- 2*35238bceSAndroid Build Coastguard Worker * drawElements C++ Base Library 3*35238bceSAndroid Build Coastguard Worker * ----------------------------- 4*35238bceSAndroid Build Coastguard Worker * 5*35238bceSAndroid Build Coastguard Worker * Copyright 2014 The Android Open Source Project 6*35238bceSAndroid Build Coastguard Worker * 7*35238bceSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License"); 8*35238bceSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License. 9*35238bceSAndroid Build Coastguard Worker * You may obtain a copy of the License at 10*35238bceSAndroid Build Coastguard Worker * 11*35238bceSAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0 12*35238bceSAndroid Build Coastguard Worker * 13*35238bceSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software 14*35238bceSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS, 15*35238bceSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16*35238bceSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and 17*35238bceSAndroid Build Coastguard Worker * limitations under the License. 18*35238bceSAndroid Build Coastguard Worker * 19*35238bceSAndroid Build Coastguard Worker *//*! 20*35238bceSAndroid Build Coastguard Worker * \file 21*35238bceSAndroid Build Coastguard Worker * \brief deProcess C++ wrapper. 22*35238bceSAndroid Build Coastguard Worker *//*--------------------------------------------------------------------*/ 23*35238bceSAndroid Build Coastguard Worker 24*35238bceSAndroid Build Coastguard Worker #include "deProcess.hpp" 25*35238bceSAndroid Build Coastguard Worker 26*35238bceSAndroid Build Coastguard Worker #include <new> 27*35238bceSAndroid Build Coastguard Worker 28*35238bceSAndroid Build Coastguard Worker namespace de 29*35238bceSAndroid Build Coastguard Worker { 30*35238bceSAndroid Build Coastguard Worker Process(void)31*35238bceSAndroid Build Coastguard WorkerProcess::Process(void) : m_process(deProcess_create()) 32*35238bceSAndroid Build Coastguard Worker { 33*35238bceSAndroid Build Coastguard Worker if (!m_process) 34*35238bceSAndroid Build Coastguard Worker throw std::bad_alloc(); 35*35238bceSAndroid Build Coastguard Worker } 36*35238bceSAndroid Build Coastguard Worker ~Process(void)37*35238bceSAndroid Build Coastguard WorkerProcess::~Process(void) 38*35238bceSAndroid Build Coastguard Worker { 39*35238bceSAndroid Build Coastguard Worker deProcess_destroy(m_process); 40*35238bceSAndroid Build Coastguard Worker } 41*35238bceSAndroid Build Coastguard Worker start(const char * commandLine,const char * workingDirectory)42*35238bceSAndroid Build Coastguard Workervoid Process::start(const char *commandLine, const char *workingDirectory) 43*35238bceSAndroid Build Coastguard Worker { 44*35238bceSAndroid Build Coastguard Worker if (!deProcess_start(m_process, commandLine, workingDirectory)) 45*35238bceSAndroid Build Coastguard Worker throw ProcessError(deProcess_getLastError(m_process)); 46*35238bceSAndroid Build Coastguard Worker } 47*35238bceSAndroid Build Coastguard Worker waitForFinish(void)48*35238bceSAndroid Build Coastguard Workervoid Process::waitForFinish(void) 49*35238bceSAndroid Build Coastguard Worker { 50*35238bceSAndroid Build Coastguard Worker if (!deProcess_waitForFinish(m_process)) 51*35238bceSAndroid Build Coastguard Worker throw ProcessError(deProcess_getLastError(m_process)); 52*35238bceSAndroid Build Coastguard Worker } 53*35238bceSAndroid Build Coastguard Worker terminate(void)54*35238bceSAndroid Build Coastguard Workervoid Process::terminate(void) 55*35238bceSAndroid Build Coastguard Worker { 56*35238bceSAndroid Build Coastguard Worker if (!deProcess_terminate(m_process)) 57*35238bceSAndroid Build Coastguard Worker throw ProcessError(deProcess_getLastError(m_process)); 58*35238bceSAndroid Build Coastguard Worker } 59*35238bceSAndroid Build Coastguard Worker kill(void)60*35238bceSAndroid Build Coastguard Workervoid Process::kill(void) 61*35238bceSAndroid Build Coastguard Worker { 62*35238bceSAndroid Build Coastguard Worker if (!deProcess_kill(m_process)) 63*35238bceSAndroid Build Coastguard Worker throw ProcessError(deProcess_getLastError(m_process)); 64*35238bceSAndroid Build Coastguard Worker } 65*35238bceSAndroid Build Coastguard Worker closeStdIn(void)66*35238bceSAndroid Build Coastguard Workervoid Process::closeStdIn(void) 67*35238bceSAndroid Build Coastguard Worker { 68*35238bceSAndroid Build Coastguard Worker if (!deProcess_closeStdIn(m_process)) 69*35238bceSAndroid Build Coastguard Worker throw ProcessError(deProcess_getLastError(m_process)); 70*35238bceSAndroid Build Coastguard Worker } 71*35238bceSAndroid Build Coastguard Worker closeStdOut(void)72*35238bceSAndroid Build Coastguard Workervoid Process::closeStdOut(void) 73*35238bceSAndroid Build Coastguard Worker { 74*35238bceSAndroid Build Coastguard Worker if (!deProcess_closeStdOut(m_process)) 75*35238bceSAndroid Build Coastguard Worker throw ProcessError(deProcess_getLastError(m_process)); 76*35238bceSAndroid Build Coastguard Worker } 77*35238bceSAndroid Build Coastguard Worker closeStdErr(void)78*35238bceSAndroid Build Coastguard Workervoid Process::closeStdErr(void) 79*35238bceSAndroid Build Coastguard Worker { 80*35238bceSAndroid Build Coastguard Worker if (!deProcess_closeStdErr(m_process)) 81*35238bceSAndroid Build Coastguard Worker throw ProcessError(deProcess_getLastError(m_process)); 82*35238bceSAndroid Build Coastguard Worker } 83*35238bceSAndroid Build Coastguard Worker 84*35238bceSAndroid Build Coastguard Worker } // namespace de 85