diff options
author | seth <getchoo@tuta.io> | 2023-08-06 15:37:44 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-06 15:37:44 -0400 |
commit | efaf4024ab22a53a3ef05f0a41b746b7561e087c (patch) | |
tree | 0c77a8ee0df72980b6d3ee0911695a1a968e133d /launcher/filelink/FileLink.cpp | |
parent | 5b8c997180ac1d7eaab8d862a90846d2c0207642 (diff) | |
parent | bae59a8c076cb3815a04fd79ee24a6a5137ab2da (diff) | |
download | PrismLauncher-efaf4024ab22a53a3ef05f0a41b746b7561e087c.tar.gz PrismLauncher-efaf4024ab22a53a3ef05f0a41b746b7561e087c.tar.bz2 PrismLauncher-efaf4024ab22a53a3ef05f0a41b746b7561e087c.zip |
Merge pull request #1464 from Ryex/fix/windows-console-attach
[Windows] Fix attaching logs to console
Diffstat (limited to 'launcher/filelink/FileLink.cpp')
-rw-r--r-- | launcher/filelink/FileLink.cpp | 27 |
1 files changed, 4 insertions, 23 deletions
diff --git a/launcher/filelink/FileLink.cpp b/launcher/filelink/FileLink.cpp index c9599b82..fb0f5fcc 100644 --- a/launcher/filelink/FileLink.cpp +++ b/launcher/filelink/FileLink.cpp @@ -37,11 +37,7 @@ #include <sys.h> #if defined Q_OS_WIN32 -#ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN -#endif -#include <stdio.h> -#include <windows.h> +#include "WindowsConsole.h" #endif // Snippet from https://github.com/gulrak/filesystem#using-it-as-single-file-header @@ -67,21 +63,7 @@ FileLinkApp::FileLinkApp(int& argc, char** argv) : QCoreApplication(argc, argv), { #if defined Q_OS_WIN32 // attach the parent console - if (AttachConsole(ATTACH_PARENT_PROCESS)) { - // if attach succeeds, reopen and sync all the i/o - if (freopen("CON", "w", stdout)) { - std::cout.sync_with_stdio(); - } - if (freopen("CON", "w", stderr)) { - std::cerr.sync_with_stdio(); - } - if (freopen("CON", "r", stdin)) { - std::cin.sync_with_stdio(); - } - auto out = GetStdHandle(STD_OUTPUT_HANDLE); - DWORD written; - const char* endline = "\n"; - WriteConsole(out, endline, strlen(endline), &written, NULL); + if (AttachWindowsConsole()) { consoleAttached = true; } #endif @@ -188,7 +170,7 @@ void FileLinkApp::runLink() FS::LinkResult result = { src_path, dst_path, QString::fromStdString(os_err.message()), os_err.value() }; m_path_results.append(result); } else { - FS::LinkResult result = { src_path, dst_path }; + FS::LinkResult result = { src_path, dst_path, "", 0}; m_path_results.append(result); } } @@ -248,7 +230,7 @@ void FileLinkApp::readPathPairs() in >> numLinks; qDebug() << "numLinks" << numLinks; - for (int i = 0; i < numLinks; i++) { + for (unsigned int i = 0; i < numLinks; i++) { FS::LinkPair pair; in >> pair.src; in >> pair.dst; @@ -271,7 +253,6 @@ FileLinkApp::~FileLinkApp() fclose(stdout); fclose(stdin); fclose(stderr); - FreeConsole(); } #endif } |