1 // =================================
 2 // Copyright (c) 2024 Seppo Laakko
 3 // Distributed under the MIT license
 4 // =================================
 5 
 6 using System.Collections;
 7 
 8 namespace System
 9 {
10     public Result<bool> Execute(const string& command)
11     {
12         int errorId = RtmExecute(command.Chars());
13         if (errorId != 0)
14         {
15             return Result<bool>(ErrorId(errorId));
16         }
17         return Result<bool>(true);
18     }
19 
20     public int Execute(const string& commandconst List<Pair<intstring>>& redirections)
21     {
22         int execHandle = RtmBeginExec(command.Chars());
23         for (const Pair<intstring>& redirection : redirections)
24         {
25             int handle = redirection.first;
26             const string& file = redirection.second;
27             RtmAddRedirection(execHandlehandlefile.Chars());
28         }
29         return RtmEndExec(execHandle);
30     }
31 
32     public string GetPathToExecutable()
33     {
34         int pathHandle = RtmBeginGetPathToExecutable();
35         string pathToExecutable = RtmGetPathToExecutable(pathHandle);
36         RtmEndGetPathToExecutable(pathHandle);
37         return pathToExecutable;
38     }