|
|
|
@ -7,8 +7,13 @@ namespace CppSharp.Utils
@@ -7,8 +7,13 @@ namespace CppSharp.Utils
|
|
|
|
|
{ |
|
|
|
|
public static string Run(string path, string args, out int error, out string errorMessage) |
|
|
|
|
{ |
|
|
|
|
using (var process = new Process()) |
|
|
|
|
return RunFrom(null, path, args, out error, out errorMessage); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static string RunFrom(string workingDir, string path, string args, out int error, out string errorMessage) |
|
|
|
|
{ |
|
|
|
|
using var process = new Process(); |
|
|
|
|
process.StartInfo.WorkingDirectory = workingDir; |
|
|
|
|
process.StartInfo.FileName = path; |
|
|
|
|
process.StartInfo.Arguments = args; |
|
|
|
|
process.StartInfo.UseShellExecute = false; |
|
|
|
@ -19,21 +24,21 @@ namespace CppSharp.Utils
@@ -19,21 +24,21 @@ namespace CppSharp.Utils
|
|
|
|
|
var retout = new StringBuilder(); |
|
|
|
|
process.OutputDataReceived += (sender, outargs) => |
|
|
|
|
{ |
|
|
|
|
if (!string.IsNullOrEmpty(outargs.Data)) |
|
|
|
|
{ |
|
|
|
|
if (string.IsNullOrEmpty(outargs.Data)) |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
if (retout.Length > 0) |
|
|
|
|
retout.AppendLine(); |
|
|
|
|
retout.Append(outargs.Data); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
process.ErrorDataReceived += (sender, errargs) => |
|
|
|
|
{ |
|
|
|
|
if (!string.IsNullOrEmpty(errargs.Data)) |
|
|
|
|
{ |
|
|
|
|
if (string.IsNullOrEmpty(errargs.Data)) |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
if (reterror.Length > 0) |
|
|
|
|
reterror.AppendLine(); |
|
|
|
|
reterror.Append(errargs.Data); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
process.Start(); |
|
|
|
@ -48,5 +53,4 @@ namespace CppSharp.Utils
@@ -48,5 +53,4 @@ namespace CppSharp.Utils
|
|
|
|
|
return retout.ToString(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|