summaryrefslogtreecommitdiffstats
path: root/source/core/slang-process-util.h
blob: 25cf0aca31e77b2056592f78f23da3e8aa566ff8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// slang-process-util.h
#ifndef SLANG_PROCESS_UTIL_H
#define SLANG_PROCESS_UTIL_H

#include "slang-process.h"

namespace Slang
{

struct ExecuteResult
{
    typedef int ResultCode;

    void init()
    {
        resultCode = 0;
        standardOutput = String();
        standardError = String();
    }

    ResultCode resultCode;
    String standardOutput;
    String standardError;
};

struct ProcessUtil
{
    /// Execute the command line
    static SlangResult execute(const CommandLine& commandLine, ExecuteResult& outExecuteResult);

    /// Read from read from streams until process terminates.
    /// Passing nullptr for a stream, will just discard what's in the stream
    static SlangResult readUntilTermination(
        Process* process,
        List<Byte>* outStdOut,
        List<Byte>* stdError);

    /// Read streams from process.
    static SlangResult readUntilTermination(Process* process, ExecuteResult& outExecuteResult);
};

} // namespace Slang

#endif // SLANG_PROCESS_UTIL_H