Commit 1bf74487 authored by DailyShana's avatar DailyShana

support multi-byte file name on Windows

parent de2e840a
......@@ -701,7 +701,9 @@ void Game::RefreshExpansionDB() {
if(fh != INVALID_HANDLE_VALUE) {
do {
if(!(fdataw.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
sprintf(fpath, "./expansions/%ls", fdataw.cFileName);
char fname[780];
BufferIO::EncodeUTF8(fdataw.cFileName, fname);
sprintf(fpath, "./expansions/%s", fname);
dataManager.LoadDB(fpath);
}
} while(FindNextFileW(fh, &fdataw));
......
......@@ -27,7 +27,15 @@ int main(int argc, char* argv[]) {
* -d: deck edit
* -r: replay */
if(argv[i][0] == '-' && argv[i][1] == 'e') {
#ifdef _WIN32
wchar_t fname[260];
MultiByteToWideChar(CP_ACP, 0, &argv[i][2], -1, fname, 260);
char fname2[260];
BufferIO::EncodeUTF8(fname, fname2);
ygo::dataManager.LoadDB(fname2);
#else
ygo::dataManager.LoadDB(&argv[i][2]);
#endif
} else if(!strcmp(argv[i], "-j") || !strcmp(argv[i], "-d") || !strcmp(argv[i], "-r") || !strcmp(argv[i], "-s")) {
exit_on_return = true;
irr::SEvent event;
......
......@@ -31,7 +31,11 @@ int SingleMode::SinglePlayThread(void* param) {
wchar_t fname[256];
myswprintf(fname, L"./single/%ls", name);
char fname2[256];
#ifdef _WIN32
size_t slen = WideCharToMultiByte(CP_ACP, 0, fname, -1, fname2, 256, NULL, NULL);
#else
size_t slen = BufferIO::EncodeUTF8(fname, fname2);
#endif
mtrandom rnd;
time_t seed = time(0);
rnd.reset(seed);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment