aboutsummaryrefslogtreecommitdiff
path: root/src/zenutil/commandlineoptions.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/zenutil/commandlineoptions.cpp')
-rw-r--r--src/zenutil/commandlineoptions.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/zenutil/commandlineoptions.cpp b/src/zenutil/commandlineoptions.cpp
index 81699361b..d94564843 100644
--- a/src/zenutil/commandlineoptions.cpp
+++ b/src/zenutil/commandlineoptions.cpp
@@ -2,7 +2,11 @@
#include <zenutil/commandlineoptions.h>
+#include <zencore/string.h>
#include <filesystem>
+
+#include <zencore/windows.h>
+
#if ZEN_WITH_TESTS
# include <zencore/testing.h>
#endif // ZEN_WITH_TESTS
@@ -160,6 +164,29 @@ RemoveQuotes(const std::string_view& Arg)
return Arg;
}
+CommandLineConverter::CommandLineConverter(int& argc, char**& argv)
+{
+#if ZEN_PLATFORM_WINDOWS
+ LPWSTR RawCommandLine = GetCommandLineW();
+ std::string CommandLine = WideToUtf8(RawCommandLine);
+ Args = ParseCommandLine(CommandLine);
+#else
+ Args.reserve(argc);
+ for (int I = 0; I < argc; I++)
+ {
+ std::string Arg(argv[I]);
+ if ((!Arg.empty()) && (Arg != " "))
+ {
+ Args.emplace_back(std::move(Arg));
+ }
+ }
+#endif
+ RawArgs = StripCommandlineQuotes(Args);
+
+ argc = static_cast<int>(RawArgs.size());
+ argv = RawArgs.data();
+}
+
#if ZEN_WITH_TESTS
void