forked from eriksvedang/cakelisp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRunProcess.hpp
53 lines (40 loc) · 1.3 KB
/
RunProcess.hpp
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
45
46
47
48
49
50
51
52
53
#pragma once
#include "Exporting.hpp"
#include "RunProcessEnums.hpp"
#include <string>
#include <vector>
struct RunProcessArguments
{
const char* fileToExecute;
// nullptr = no change (use parent process's working dir)
const char* workingDirectory;
const char** arguments;
};
CAKELISP_API int runProcess(const RunProcessArguments& arguments, int* statusOut);
typedef void (*SubprocessOnOutputFunc)(const char* subprocessOutput);
CAKELISP_API void waitForAllProcessesClosed(SubprocessOnOutputFunc onOutput);
//
// Helpers for programmatically constructing arguments
//
struct ProcessCommandArgument
{
ProcessCommandArgumentType type;
std::string contents;
};
struct ProcessCommand
{
std::string fileToExecute;
std::vector<ProcessCommandArgument> arguments;
};
struct ProcessCommandInput
{
ProcessCommandArgumentType type;
std::vector<const char*> value;
};
void PrintProcessArguments(const char** processArguments);
// The array will need to be deleted, but the array members will not
// All strings need to exist and not be moved until after you call runProcess
CAKELISP_API const char** MakeProcessArgumentsFromCommand(
const char* fileToExecute, std::vector<ProcessCommandArgument>& arguments,
const ProcessCommandInput* inputs, int numInputs);
extern const int maxProcessesRecommendedSpawned;