fs/Traits: enable _UNICODE on Windows
Use wchar_t for everything on Windows. Solves a lot of filesystem charset problems.
This commit is contained in:
@@ -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 */
|
||||
|
Reference in New Issue
Block a user