| 88 | } |
| 89 | |
| 90 | int wmain(int argc, wchar_t* argv[], wchar_t* envp[]) |
| 91 | { |
| 92 | // set control signal handler |
| 93 | SetConsoleCtrlHandler(ControlHandler, TRUE); |
| 94 | // prepare utf8 console |
| 95 | UINT originalCP = GetConsoleCP(); |
| 96 | UINT originalOutputCP = GetConsoleOutputCP(); |
| 97 | auto revertConsoleCP = wil::scope_exit([=]() |
| 98 | { |
| 99 | SetConsoleCP(originalCP); |
| 100 | SetConsoleOutputCP(originalOutputCP); |
| 101 | std::wcout << SetOutputDefault; |
| 102 | }); |
| 103 | SetConsoleCP(CP_UTF8); |
| 104 | SetConsoleOutputCP(CP_UTF8); |
| 105 | setlocale(LC_ALL, ".UTF8"); |
| 106 | // cin/wcin is broken for wide characters |
| 107 | // use helper function instead |
| 108 | // use wcout to print wide string |
| 109 | // use cout to print utf8 string |
| 110 | std::wcout.imbue(std::locale(".UTF8")); |
| 111 | std::wcerr.imbue(std::locale(".UTF8")); |
| 112 | |
| 113 | try |
| 114 | { |
| 115 | // validate arguments |
| 116 | std::vector<std::wstring> input; |
| 117 | std::wstring output; |
| 118 | bool deduplicate; |
| 119 | try |
| 120 | { |
| 121 | FindOptions(argc, argv, input, output, deduplicate); |
| 122 | } |
| 123 | catch (std::exception& e) |
| 124 | { |
| 125 | std::cout << SetOutputRed << e.what() << std::endl; |
| 126 | PrintHelp(); |
| 127 | return 1; |
| 128 | } |
| 129 | |
| 130 | std::wcout << SetOutputDefault << "Current Directory: \n " << SetOutputYellow << GetCurrentDirectory().get() |
| 131 | << std::endl; |
| 132 | |
| 133 | std::wcout << SetOutputDefault << "Input directory: \n"; |
| 134 | for (auto& i : input) |
| 135 | { |
| 136 | if (!IsDirectory(i.c_str())) |
| 137 | { |
| 138 | std::wcout << " " << SetOutputRed << i << " is not a directory!" << std::endl; |
| 139 | return 1; |
| 140 | } |
| 141 | std::wcout << " " << SetOutputYellow << i << std::endl; |
| 142 | } |
| 143 | |
| 144 | if (output.empty()) |
| 145 | { |
| 146 | std::wcout << SetOutputYellow << "Output file path not specified. Generate path from first input." << |
| 147 | std::endl; |
nothing calls this directly
no test coverage detected