aboutsummaryrefslogtreecommitdiff
path: root/zenserver/config.cpp
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2022-08-26 13:37:19 +0200
committerGitHub <[email protected]>2022-08-26 04:37:19 -0700
commit57ba63d2f63847934b8d197a77c1eca292ed6e41 (patch)
treebce9d3038b3eadc83f6b330dee3300509ec550cf /zenserver/config.cpp
parentredefine vcpkg cache naming (diff)
downloadzen-57ba63d2f63847934b8d197a77c1eca292ed6e41.tar.xz
zen-57ba63d2f63847934b8d197a77c1eca292ed6e41.zip
Use "\\?\" prefixed paths and fix hardcoded path delimiters (#149)
* use "\\?\" prefix for windows paths * fix path delimiters * disable vcpkg caching * Workaround for spdlog not being able to create directories prefixed with `\\?\`
Diffstat (limited to 'zenserver/config.cpp')
-rw-r--r--zenserver/config.cpp30
1 files changed, 24 insertions, 6 deletions
diff --git a/zenserver/config.cpp b/zenserver/config.cpp
index c534865dc..6581b2109 100644
--- a/zenserver/config.cpp
+++ b/zenserver/config.cpp
@@ -487,8 +487,7 @@ ParseCliOptions(int argc, char* argv[], ZenServerOptions& ServerOptions)
"");
try
{
- auto result = options.parse(argc, argv);
- ServerOptions.DataDir = DataDir;
+ auto result = options.parse(argc, argv);
if (result.count("help"))
{
@@ -503,10 +502,29 @@ ParseCliOptions(int argc, char* argv[], ZenServerOptions& ServerOptions)
exit(0);
}
- ServerOptions.DataDir = DataDir;
- ServerOptions.ContentDir = ContentDir;
- ServerOptions.AbsLogFile = AbsLogFile;
- ServerOptions.ConfigFile = ConfigFile;
+ auto MakeSafePath = [](const std::string& Path) {
+#if ZEN_PLATFORM_WINDOWS
+ if (Path.empty())
+ {
+ return Path;
+ }
+
+ std::string FixedPath = Path;
+ std::replace(FixedPath.begin(), FixedPath.end(), '/', '\\');
+ if (!FixedPath.starts_with("\\\\?\\"))
+ {
+ FixedPath.insert(0, "\\\\?\\");
+ }
+ return FixedPath;
+#else
+ return Path;
+#endif
+ };
+
+ ServerOptions.DataDir = MakeSafePath(DataDir);
+ ServerOptions.ContentDir = MakeSafePath(ContentDir);
+ ServerOptions.AbsLogFile = MakeSafePath(AbsLogFile);
+ ServerOptions.ConfigFile = MakeSafePath(ConfigFile);
ServerOptions.UpstreamCacheConfig.CachePolicy = ParseUpstreamCachePolicy(UpstreamCachePolicyOptions);
if (!ServerOptions.ConfigFile.empty())