mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-08-17 21:51:20 +02:00
Add 'console' command line argument
This opens a console window on Windows but does nothing anywhere else. Overrides 'redirect'. Useful on Windows because the only way to access standard streams there is by tail -f'ing stdout/err.txt.
This commit is contained in:
@@ -124,5 +124,6 @@ Command Line
|
|||||||
| `disable-network` | Disables internet connections | |
|
| `disable-network` | Disables internet connections | |
|
||||||
| `disable-bluescreen` | Disable bluescreen handler | |
|
| `disable-bluescreen` | Disable bluescreen handler | |
|
||||||
| `redirect` | Redirects output to stdout.txt / stderr.txt | |
|
| `redirect` | Redirects output to stdout.txt / stderr.txt | |
|
||||||
|
| `console` | Redirects output to a new console on Windows | |
|
||||||
| `cafile:CAFILE` | Set certificate bundle path | `cafile:/etc/ssl/certs/ca-certificates.crt` |
|
| `cafile:CAFILE` | Set certificate bundle path | `cafile:/etc/ssl/certs/ca-certificates.crt` |
|
||||||
| `capath:CAPATH` | Set certificate directory path | `capath:/etc/ssl/certs` |
|
| `capath:CAPATH` | Set certificate directory path | `capath:/etc/ssl/certs` |
|
||||||
|
@@ -380,7 +380,11 @@ int Main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto redirectStd = prefs.Get("RedirectStd", false);
|
auto redirectStd = prefs.Get("RedirectStd", false);
|
||||||
if (true_arg(arguments["redirect"]) || redirectStd)
|
if (true_arg(arguments["console"]))
|
||||||
|
{
|
||||||
|
Platform::AllocConsole();
|
||||||
|
}
|
||||||
|
else if (true_arg(arguments["redirect"]) || redirectStd)
|
||||||
{
|
{
|
||||||
FILE *new_stdout = freopen("stdout.log", "w", stdout);
|
FILE *new_stdout = freopen("stdout.log", "w", stdout);
|
||||||
FILE *new_stderr = freopen("stderr.log", "w", stderr);
|
FILE *new_stderr = freopen("stderr.log", "w", stderr);
|
||||||
|
@@ -74,6 +74,7 @@ namespace Platform
|
|||||||
std::optional<std::vector<String>> StackTrace();
|
std::optional<std::vector<String>> StackTrace();
|
||||||
|
|
||||||
void MarkPresentable();
|
void MarkPresentable();
|
||||||
|
void AllocConsole();
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" int Main(int argc, char *argv[]);
|
extern "C" int Main(int argc, char *argv[]);
|
||||||
|
@@ -150,4 +150,8 @@ std::vector<ByteString> DirectoryList(ByteString directory)
|
|||||||
closedir(directoryHandle);
|
closedir(directoryHandle);
|
||||||
return directoryList;
|
return directoryList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AllocConsole()
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -10,6 +10,7 @@
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <crtdbg.h>
|
#include <crtdbg.h>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
namespace Platform
|
namespace Platform
|
||||||
{
|
{
|
||||||
@@ -409,4 +410,14 @@ void SetupCrt()
|
|||||||
std::cerr << "failed to set codepage to utf-8, expect breakage" << std::endl;
|
std::cerr << "failed to set codepage to utf-8, expect breakage" << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AllocConsole()
|
||||||
|
{
|
||||||
|
if (!::AllocConsole())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
freopen("CONOUT$", "w", stdout);
|
||||||
|
freopen("CONOUT$", "w", stderr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user