From 65ff72cdf8d3fc8664893b55ca47fca284f34d87 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 25 Feb 2015 16:01:46 +0100 Subject: fs/Traits: enable _UNICODE on Windows Use wchar_t for everything on Windows. Solves a lot of filesystem charset problems. --- src/CommandLine.cxx | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/CommandLine.cxx') diff --git a/src/CommandLine.cxx b/src/CommandLine.cxx index e87b1676f..1a55a29ea 100644 --- a/src/CommandLine.cxx +++ b/src/CommandLine.cxx @@ -35,6 +35,7 @@ #include "fs/Traits.hxx" #include "fs/FileSystem.hxx" #include "fs/StandardDirectory.hxx" +#include "util/Macros.hxx" #include "util/Error.hxx" #include "util/Domain.hxx" #include "util/OptionDef.hxx" @@ -337,7 +338,19 @@ parse_cmdline(int argc, char **argv, struct options *options, if (config_file != nullptr) { /* use specified configuration file */ +#ifdef _UNICODE + wchar_t buffer[MAX_PATH]; + auto result = MultiByteToWideChar(CP_ACP, 0, config_file, -1, + buffer, ARRAY_SIZE(buffer)); + if (result <= 0) { + error.SetLastError("MultiByteToWideChar() failed"); + return false; + } + + return ReadConfigFile(Path::FromFS(buffer), error); +#else return ReadConfigFile(Path::FromFS(config_file), error); +#endif } /* use default configuration file path */ -- cgit v1.2.3