| 303 | } |
| 304 | |
| 305 | void run() |
| 306 | { |
| 307 | const char* nextFile = nullptr; |
| 308 | |
| 309 | if (saving ? GetSaveFileNameW(&ofn) : GetOpenFileNameW(&ofn)) |
| 310 | { |
| 311 | if (threadCancelled) |
| 312 | { |
| 313 | threadHandle = 0; |
| 314 | return; |
| 315 | } |
| 316 | |
| 317 | // back to UTF-8 |
| 318 | std::vector<char> fileNameA(4 * 32768); |
| 319 | if (WideCharToMultiByte(CP_UTF8, 0, fileNameW.data(), -1, |
| 320 | fileNameA.data(), (int)fileNameA.size(), |
| 321 | nullptr, nullptr)) |
| 322 | { |
| 323 | nextFile = strdup(fileNameA.data()); |
| 324 | } |
| 325 | } |
| 326 | |
| 327 | if (threadCancelled) |
| 328 | { |
| 329 | threadHandle = 0; |
| 330 | return; |
| 331 | } |
| 332 | |
| 333 | if (nextFile == nullptr) |
| 334 | nextFile = kSelectedFileCancelled; |
| 335 | |
| 336 | selectedFile = nextFile; |
| 337 | threadHandle = 0; |
| 338 | } |
| 339 | |
| 340 | static unsigned __stdcall _run(void* const arg) |
| 341 | { |