fix: cannot recognize non-ASCII file name on Windows
This commit is contained in:
parent
1cfc29560d
commit
5cfe439e48
|
@ -10,8 +10,8 @@ add_subdirectory(taglib)
|
|||
FILE(GLOB HEADERS ./*.h)
|
||||
FILE(GLOB SOURCES ./*.cpp)
|
||||
add_executable(ncmdump
|
||||
${HEADERS}
|
||||
${SOURCES}
|
||||
${HEADERS}
|
||||
${SOURCES}
|
||||
)
|
||||
target_link_libraries(ncmdump tag)
|
||||
target_include_directories(ncmdump PRIVATE taglib)
|
||||
|
@ -19,9 +19,15 @@ target_include_directories(ncmdump PRIVATE taglib/taglib)
|
|||
target_include_directories(ncmdump PRIVATE taglib/taglib/toolkit)
|
||||
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)
|
||||
install(TARGETS ncmdump
|
||||
BUNDLE DESTINATION .
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
BUNDLE DESTINATION .
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
)
|
||||
|
|
16
main.cpp
16
main.cpp
|
@ -5,7 +5,7 @@
|
|||
#include <vector>
|
||||
#include <filesystem>
|
||||
|
||||
#if defined(_WIN32) && defined(_MSC_VER)
|
||||
#if defined(_WIN32)
|
||||
#include <Windows.h>
|
||||
#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[])
|
||||
#else
|
||||
int main(int argc, char **argv)
|
||||
#endif
|
||||
{
|
||||
#if defined(_WIN32) && defined(_MSC_VER)
|
||||
#if defined(_WIN32) && defined(__MINGW64__)
|
||||
SetConsoleOutputCP(CP_UTF8);
|
||||
#endif
|
||||
|
||||
|
@ -67,7 +67,7 @@ int main(int argc, char **argv)
|
|||
|
||||
bool folderProvided = false;
|
||||
|
||||
#if defined(_WIN32) && defined(_MSC_VER)
|
||||
#if defined(_WIN32)
|
||||
#define COMPARE_STR(s1, s2) (wcscmp(s1, s2) == 0)
|
||||
#define HELP_SHORT L"-h"
|
||||
#define HELP_LONG L"--help"
|
||||
|
@ -95,11 +95,9 @@ int main(int argc, char **argv)
|
|||
return 1;
|
||||
}
|
||||
} else {
|
||||
#if defined(_WIN32) && defined(_MSC_VER)
|
||||
int multiByteStrSize = WideCharToMultiByte(CP_UTF8, 0, argv[1], -1, NULL, 0, NULL, NULL);
|
||||
char *multiByteStr = new char[multiByteStrSize];
|
||||
WideCharToMultiByte(CP_UTF8, 0, argv[i], -1, multiByteStr, multiByteStrSize, NULL, NULL);
|
||||
fs::path path(multiByteStr);
|
||||
#if defined(_WIN32)
|
||||
std::wstring wFilePath(argv[i]);
|
||||
fs::path path(wFilePath);
|
||||
#else
|
||||
fs::path path(argv[i]);
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue