aboutsummaryrefslogtreecommitdiff
path: root/zenserver/config.cpp
diff options
context:
space:
mode:
authorMartin Ridgers <[email protected]>2022-01-25 11:38:44 +0100
committerMartin Ridgers <[email protected]>2022-01-25 11:38:44 +0100
commit5abb6a2c08329839432b30f5d70b22ddac1dca1f (patch)
tree41a4e85e81df6cd539a6a2226830bd807f4d9450 /zenserver/config.cpp
parentAdded generateprojects.bat (diff)
downloadzen-5abb6a2c08329839432b30f5d70b22ddac1dca1f.tar.xz
zen-5abb6a2c08329839432b30f5d70b22ddac1dca1f.zip
Command line paths containing whitespace were getting truncated
Diffstat (limited to 'zenserver/config.cpp')
-rw-r--r--zenserver/config.cpp22
1 files changed, 18 insertions, 4 deletions
diff --git a/zenserver/config.cpp b/zenserver/config.cpp
index 4afe012dd..3c4f6f3d8 100644
--- a/zenserver/config.cpp
+++ b/zenserver/config.cpp
@@ -91,6 +91,16 @@ ParseCliOptions(int argc, char* argv[], ZenServerOptions& ServerOptions)
const char* DefaultHttp = "asio";
#endif
+ // Note to those adding future options; std::filesystem::path-type options
+ // must be read into a std::string first. As of cxxopts-3.0.0 it uses a >>
+ // stream operator to convert argv value into the options type. std::fs::path
+ // expects paths in streams to be quoted but argv paths are unquoted. By
+ // going into a std::string first, paths with whitespace parse correctly.
+ std::string DataDir;
+ std::string ContentDir;
+ std::string AbsLogFile;
+ std::string ConfigFile;
+
cxxopts::Options options("zenserver", "Zen Server");
options.add_options()("dedicated",
"Enable dedicated server mode",
@@ -99,10 +109,10 @@ ParseCliOptions(int argc, char* argv[], ZenServerOptions& ServerOptions)
options.add_options()("help", "Show command line help");
options.add_options()("t, test", "Enable test mode", cxxopts::value<bool>(ServerOptions.IsTest)->default_value("false"));
options.add_options()("log-id", "Specify id for adding context to log output", cxxopts::value<std::string>(ServerOptions.LogId));
- options.add_options()("data-dir", "Specify persistence root", cxxopts::value<std::filesystem::path>(ServerOptions.DataDir));
- options.add_options()("content-dir", "Frontend content directory", cxxopts::value<std::filesystem::path>(ServerOptions.ContentDir));
- options.add_options()("abslog", "Path to log file", cxxopts::value<std::filesystem::path>(ServerOptions.AbsLogFile));
- options.add_options()("config", "Path to Lua config file", cxxopts::value<std::filesystem::path>(ServerOptions.ConfigFile));
+ options.add_options()("data-dir", "Specify persistence root", cxxopts::value<std::string>(DataDir));
+ options.add_options()("content-dir", "Frontend content directory", cxxopts::value<std::string>(ContentDir));
+ options.add_options()("abslog", "Path to log file", cxxopts::value<std::string>(AbsLogFile));
+ options.add_options()("config", "Path to Lua config file", cxxopts::value<std::string>(ConfigFile));
options.add_options()("no-sentry",
"Disable Sentry crash handler",
cxxopts::value<bool>(ServerOptions.NoSentry)->default_value("false"));
@@ -327,6 +337,10 @@ ParseCliOptions(int argc, char* argv[], ZenServerOptions& ServerOptions)
exit(0);
}
+ ServerOptions.DataDir = DataDir;
+ ServerOptions.ContentDir = ContentDir;
+ ServerOptions.AbsLogFile = AbsLogFile;
+ ServerOptions.ConfigFile = ConfigFile;
ServerOptions.UpstreamCacheConfig.CachePolicy = ParseUpstreamCachePolicy(UpstreamCachePolicyOptions);
if (!ServerOptions.ConfigFile.empty())