mirror of
https://github.com/RPCSX/rpcsx.git
synced 2026-04-06 23:15:18 +00:00
Move freopen to console.h
This commit is contained in:
parent
dfec577417
commit
16f006362e
7 changed files with 88 additions and 62 deletions
39
rpcs3/util/console.cpp
Normal file
39
rpcs3/util/console.cpp
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
#include "console.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "Windows.h"
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
namespace utils
|
||||
{
|
||||
void attach_console([[maybe_unused]] int stream, [[maybe_unused]] bool open_console)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
if (!stream)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(AttachConsole(ATTACH_PARENT_PROCESS) || (open_console && AllocConsole())))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (stream & console_stream::std_out)
|
||||
{
|
||||
[[maybe_unused]] const auto con_out = freopen("CONOUT$", "w", stdout);
|
||||
}
|
||||
|
||||
if (stream & console_stream::std_err)
|
||||
{
|
||||
[[maybe_unused]] const auto con_err = freopen("CONOUT$", "w", stderr);
|
||||
}
|
||||
|
||||
if (stream & console_stream::std_in)
|
||||
{
|
||||
[[maybe_unused]] const auto con_in = freopen("CONIN$", "r", stdin);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue