-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProcessOperationBase.cs
More file actions
83 lines (72 loc) · 2.07 KB
/
ProcessOperationBase.cs
File metadata and controls
83 lines (72 loc) · 2.07 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
namespace PKGE.Editor
{
public class ProcessOperationBase
{
//https://github.com/Unity-Technologies/Graphics/blob/504e639c4e07492f74716f36acf7aad0294af16e/Packages/com.unity.shaderanalysis/Editor/Internal/ProcessOperationBase.cs
#region UnityEditor.ShaderAnalysis.PSSLInternal
readonly List<string> _errors = new List<string> { string.Empty };
readonly StringBuilder _errorBuilder = new StringBuilder();
readonly List<string> _lines = new List<string>();
readonly StringBuilder _outputBuilder = new StringBuilder();
readonly Process _process;
public List<string> errors
{
get
{
Flush();
return _errors;
}
}
public List<string> lines
{
get
{
Flush();
return _lines;
}
}
public string output
{
get
{
Flush();
return _outputBuilder.ToString();
}
}
public ProcessOperationBase(Process process)
{
_process = process;
}
public bool isComplete
{
get
{
return _process.HasExited;
}
}
public void Cancel()
{
if (!_process.HasExited)
_process.Kill();
}
void Flush()
{
while (_process.StandardError.Peek() > -1)
{
var line = _process.StandardError.ReadLine();
_errorBuilder.AppendLine(line);
}
_errors[0] = _errorBuilder.ToString();
while (_process.StandardOutput.Peek() > -1)
{
var line = _process.StandardOutput.ReadLine();
_lines.Add(line);
_outputBuilder.AppendLine(line);
}
}
#endregion // UnityEditor.ShaderAnalysis.PSSLInternal
}
}