您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
80 行
1.8 KiB
80 行
1.8 KiB
using System.Collections.Generic;
|
|
using System.Diagnostics;
|
|
using System.Text;
|
|
|
|
namespace UnityEditor.Experimental.ShaderTools.PSSLInternal
|
|
{
|
|
class ProcessOperationBase
|
|
{
|
|
List<string> m_Errors = new List<string> { string.Empty };
|
|
StringBuilder m_ErrorBuilder = new StringBuilder();
|
|
|
|
List<string> m_Lines = new List<string>();
|
|
StringBuilder m_OutputBuilder = new StringBuilder();
|
|
|
|
public List<string> errors
|
|
{
|
|
get
|
|
{
|
|
Flush();
|
|
return m_Errors;
|
|
}
|
|
}
|
|
|
|
public List<string> lines
|
|
{
|
|
get
|
|
{
|
|
Flush();
|
|
return m_Lines;
|
|
}
|
|
}
|
|
|
|
public string output
|
|
{
|
|
get
|
|
{
|
|
Flush();
|
|
return m_OutputBuilder.ToString();
|
|
}
|
|
}
|
|
|
|
Process m_Process = null;
|
|
|
|
public ProcessOperationBase(Process process)
|
|
{
|
|
m_Process = process;
|
|
}
|
|
|
|
public bool isComplete
|
|
{
|
|
get
|
|
{
|
|
return m_Process.HasExited;
|
|
}
|
|
}
|
|
|
|
public void Cancel()
|
|
{
|
|
if (!m_Process.HasExited)
|
|
m_Process.Kill();
|
|
}
|
|
|
|
void Flush()
|
|
{
|
|
while (m_Process.StandardError.Peek() > -1)
|
|
{
|
|
var line = m_Process.StandardError.ReadLine();
|
|
m_ErrorBuilder.AppendLine(line);
|
|
}
|
|
m_Errors[0] = m_ErrorBuilder.ToString();
|
|
|
|
while (m_Process.StandardOutput.Peek() > -1)
|
|
{
|
|
var line = m_Process.StandardOutput.ReadLine();
|
|
m_Lines.Add(line);
|
|
m_OutputBuilder.AppendLine(line);
|
|
}
|
|
}
|
|
}
|
|
}
|