mirror of
https://github.com/RPCSX/rpcsx.git
synced 2026-04-07 07:25:26 +00:00
split rpcs3 and hle libraries
merge rpcs3 utilities
This commit is contained in:
parent
b33e2662b6
commit
62ad27d1e2
1233 changed files with 7004 additions and 3819 deletions
61
rpcs3/util/console.cpp
Normal file
61
rpcs3/util/console.cpp
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
#include "console.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
void output_stderr(std::string_view str, bool with_endline)
|
||||
{
|
||||
if (with_endline)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
std::clog << str;
|
||||
#else
|
||||
std::cerr << str;
|
||||
#endif
|
||||
str = "\n";
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
// Flush seems broken on Windows (deadlocks)
|
||||
std::clog << str;
|
||||
#else
|
||||
std::cerr << str;
|
||||
#endif
|
||||
}
|
||||
} // namespace utils
|
||||
Loading…
Add table
Add a link
Reference in a new issue