fix: cannot recognize non-ASCII file name on Windows
This commit is contained in:
parent
1cfc29560d
commit
5cfe439e48
|
@ -19,6 +19,12 @@ target_include_directories(ncmdump PRIVATE taglib/taglib)
|
||||||
target_include_directories(ncmdump PRIVATE taglib/taglib/toolkit)
|
target_include_directories(ncmdump PRIVATE taglib/taglib/toolkit)
|
||||||
target_include_directories(ncmdump PRIVATE taglib/taglib/mpeg/id3v2)
|
target_include_directories(ncmdump PRIVATE taglib/taglib/mpeg/id3v2)
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||||
|
target_link_options(ncmdump PRIVATE -O2 -municode)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
install(TARGETS ncmdump
|
install(TARGETS ncmdump
|
||||||
BUNDLE DESTINATION .
|
BUNDLE DESTINATION .
|
||||||
|
|
16
main.cpp
16
main.cpp
|
@ -5,7 +5,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
|
||||||
#if defined(_WIN32) && defined(_MSC_VER)
|
#if defined(_WIN32)
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -47,13 +47,13 @@ void processFilesInFolder(const fs::path& folderPath) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(_WIN32) && defined(_MSC_VER)
|
#if defined(_WIN32)
|
||||||
int wmain(int argc, wchar_t* argv[])
|
int wmain(int argc, wchar_t* argv[])
|
||||||
#else
|
#else
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
#if defined(_WIN32) && defined(_MSC_VER)
|
#if defined(_WIN32) && defined(__MINGW64__)
|
||||||
SetConsoleOutputCP(CP_UTF8);
|
SetConsoleOutputCP(CP_UTF8);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
bool folderProvided = false;
|
bool folderProvided = false;
|
||||||
|
|
||||||
#if defined(_WIN32) && defined(_MSC_VER)
|
#if defined(_WIN32)
|
||||||
#define COMPARE_STR(s1, s2) (wcscmp(s1, s2) == 0)
|
#define COMPARE_STR(s1, s2) (wcscmp(s1, s2) == 0)
|
||||||
#define HELP_SHORT L"-h"
|
#define HELP_SHORT L"-h"
|
||||||
#define HELP_LONG L"--help"
|
#define HELP_LONG L"--help"
|
||||||
|
@ -95,11 +95,9 @@ int main(int argc, char **argv)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
#if defined(_WIN32) && defined(_MSC_VER)
|
#if defined(_WIN32)
|
||||||
int multiByteStrSize = WideCharToMultiByte(CP_UTF8, 0, argv[1], -1, NULL, 0, NULL, NULL);
|
std::wstring wFilePath(argv[i]);
|
||||||
char *multiByteStr = new char[multiByteStrSize];
|
fs::path path(wFilePath);
|
||||||
WideCharToMultiByte(CP_UTF8, 0, argv[i], -1, multiByteStr, multiByteStrSize, NULL, NULL);
|
|
||||||
fs::path path(multiByteStr);
|
|
||||||
#else
|
#else
|
||||||
fs::path path(argv[i]);
|
fs::path path(argv[i]);
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue