| 100 | } |
| 101 | |
| 102 | bool AttachWindowsConsole() |
| 103 | { |
| 104 | auto stdinType = GetFileType(GetStdHandle(STD_INPUT_HANDLE)); |
| 105 | auto stdoutType = GetFileType(GetStdHandle(STD_OUTPUT_HANDLE)); |
| 106 | auto stderrType = GetFileType(GetStdHandle(STD_ERROR_HANDLE)); |
| 107 | |
| 108 | bool bindStdIn = false; |
| 109 | bool bindStdOut = false; |
| 110 | bool bindStdErr = false; |
| 111 | |
| 112 | if (stdinType == FILE_TYPE_CHAR || stdinType == FILE_TYPE_UNKNOWN) { |
| 113 | bindStdIn = true; |
| 114 | } |
| 115 | if (stdoutType == FILE_TYPE_CHAR || stdoutType == FILE_TYPE_UNKNOWN) { |
| 116 | bindStdOut = true; |
| 117 | } |
| 118 | if (stderrType == FILE_TYPE_CHAR || stderrType == FILE_TYPE_UNKNOWN) { |
| 119 | bindStdErr = true; |
| 120 | } |
| 121 | |
| 122 | if (AttachConsole(ATTACH_PARENT_PROCESS)) { |
| 123 | BindCrtHandlesToStdHandles(bindStdIn, bindStdOut, bindStdErr); |
| 124 | return true; |
| 125 | } |
| 126 | |
| 127 | return false; |
| 128 | } |
no test coverage detected