diff options
author | Max Kellermann <max@duempel.org> | 2015-02-25 16:01:46 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2015-03-05 10:15:10 +0100 |
commit | 65ff72cdf8d3fc8664893b55ca47fca284f34d87 (patch) | |
tree | 766eca97378aa4567d7e55aba24c4a785f956f9d /src/CommandLine.cxx | |
parent | 1da09563310a666095e93d3b4fdc5556a8a7c534 (diff) |
fs/Traits: enable _UNICODE on Windows
Use wchar_t for everything on Windows. Solves a lot of filesystem
charset problems.
Diffstat (limited to 'src/CommandLine.cxx')
-rw-r--r-- | src/CommandLine.cxx | 13 |
1 files changed, 13 insertions, 0 deletions
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 */ |