1
2
3
4
5
6 #ifndef SOULNG_UTIL_SYSTEM_INCLUDED
7 #define SOULNG_UTIL_SYSTEM_INCLUDED
8 #include <soulng/util/UtilApi.hpp>
9 #include <string>
10 #include <vector>
11 #include <map>
12 #include <stdexcept>
13
14 namespace soulng { namespace util {
15
16 class ProcessFailure : public std::runtime_error
17 {
18 public:
19 ProcessFailure(const std::string& errorMessage_, int exitCode_);
20 int ExitCode() const { return exitCode; }
21 private:
22 int exitCode;
23 };
24
25 void DisableConsoleWindow();
26 void System(const std::string& command);
27 void System(const std::string& command, bool ignoreReturnValue);
28 void System(const std::string& command, int redirectFd, const std::string& toFile);
29 void System(const std::string& command, int redirectFd, const std::string& toFile, bool ignoreReturnValue);
30 void System(const std::string& command, const std::std::vector<std::std::pair<int, std::string>>&redirections);
31 unsigned long long Spawn(const std::string& filename, const std::std::vector<std::string>&args);
32 int Wait(unsigned long long processHandle);
33 int ReadFromPipe(int pipeHandle, void* buffer, unsigned int count);
34 int WriteToPipe(int pipeHandle, void* buffer, unsigned int count);
35 void RedirectStdHandlesToPipes(std::std::vector<int>&oldHandles, std::std::vector<int>&pipeHandles);
36 void RestoreStdHandles(const std::std::vector<int>&oldHandles);
37 std::string GetPathToExecutable();
38
39 } }
40
41 #endif // SOULNG_UTIL_SYSTEM_INCLUDED