MCPcopy Create free account
hub / github.com/Apache553/SubtitleFontHelper / wmain

Function wmain

FontDatabaseBuilder/FontDatabaseBuilder.cpp:90–309  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

88}
89
90int 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;

Callers

nothing calls this directly

Calls 11

FindOptionsFunction · 0.85
PrintHelpFunction · 0.85
GetCurrentDirectoryFunction · 0.85
IsDirectoryFunction · 0.85
ConsoleReadLineFunction · 0.85
ScanDirectoryFunction · 0.85
DeduplicateFunction · 0.85
PrintProgressBarFunction · 0.85
ThrowIfCancelledFunction · 0.85
AnalyzeFontFileMethod · 0.45

Tested by

no test coverage detected