forked from CobaltFusion/DebugViewPP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProcessReader.cpp
More file actions
47 lines (39 loc) · 1.51 KB
/
Copy pathProcessReader.cpp
File metadata and controls
47 lines (39 loc) · 1.51 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
// (C) Copyright Gert-Jan de Vos and Jan Wilmans 2013.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include "CobaltFusion/Str.h"
#include "DebugViewppLib/PolledLogSource.h"
#include "DebugViewppLib/ProcessReader.h"
#include "DebugViewppLib/LineBuffer.h"
namespace fusion {
namespace debugviewpp {
ProcessReader::ProcessReader(Timer& timer, ILineBuffer& linebuffer, const std::wstring& pathName, const std::wstring& args) :
PolledLogSource(timer, SourceType::Pipe, linebuffer, 40),
m_process(pathName, args),
m_stdout(timer, linebuffer, m_process.GetStdOut(), m_process.GetProcessId(), Str(m_process.GetName()).str() + ":stdout", 0),
m_stderr(timer, linebuffer, m_process.GetStdErr(), m_process.GetProcessId(), Str(m_process.GetName()).str() + ":stderr", 0)
{
SetDescription(m_process.GetName() + L" stdout/stderr");
AddMessage(Win32::DuplicateHandle(m_process.GetProcessHandle()), "Started capturing output of stdout/stderr");
Signal();
StartThread();
}
ProcessReader::~ProcessReader() = default;
void ProcessReader::Abort()
{
AddMessage(m_process.GetProcessId(), Str(m_process.GetName()).str(), "<process reader aborted>");
Signal();
PolledLogSource::Abort();
}
bool ProcessReader::AtEnd() const
{
return m_stdout.AtEnd() && m_stderr.AtEnd();
}
void ProcessReader::Poll()
{
m_stdout.Poll(*this);
m_stderr.Poll(*this);
}
} // namespace debugviewpp
} // namespace fusion