MCPcopy Create free account
hub / github.com/abbeycode/UnrarKit / InitConsole

Function InitConsole

Libraries/unrar/consio.cpp:21–49  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19
20
21void InitConsole()
22{
23#ifdef _WIN_ALL
24 // We want messages like file names or progress percent to be printed
25 // immediately. Use only in Windows, in Unix they can cause wprintf %ls
26 // to fail with non-English strings.
27 setbuf(stdout,NULL);
28 setbuf(stderr,NULL);
29
30 // Detect if output is redirected and set output mode properly.
31 // We do not want to send Unicode output to files and especially to pipes
32 // like '|more', which cannot handle them correctly in Windows.
33 // In Unix console output is UTF-8 and it is handled correctly
34 // when redirecting, so no need to perform any adjustments.
35 StdoutRedirected=IsRedirected(STD_OUTPUT_HANDLE);
36 StderrRedirected=IsRedirected(STD_ERROR_HANDLE);
37 StdinRedirected=IsRedirected(STD_INPUT_HANDLE);
38#ifdef _MSC_VER
39 if (!StdoutRedirected)
40 _setmode(_fileno(stdout), _O_U16TEXT);
41 if (!StderrRedirected)
42 _setmode(_fileno(stderr), _O_U16TEXT);
43#endif
44#elif defined(_UNIX)
45 StdoutRedirected=!isatty(fileno(stdout));
46 StderrRedirected=!isatty(fileno(stderr));
47 StdinRedirected=!isatty(fileno(stdin));
48#endif
49}
50
51
52void SetConsoleMsgStream(MESSAGE_TYPE MsgStream)

Callers 1

mainFunction · 0.85

Calls 1

IsRedirectedFunction · 0.85

Tested by

no test coverage detected