| 279 | // ------------------------------------------------- |
| 280 | |
| 281 | std::filesystem::path pathFromConsoleString(const std::string &path) |
| 282 | { |
| 283 | #if defined(_WIN32) |
| 284 | // Use windows string conversion api due to mingw64 limitations. |
| 285 | int nCodePage = GetConsoleCP(); |
| 286 | int convertResult = |
| 287 | MultiByteToWideChar(nCodePage, 0, path.c_str(), (int)path.length(), nullptr, 0); |
| 288 | |
| 289 | if (convertResult > 0) { |
| 290 | std::wstring widePath; |
| 291 | widePath.resize(convertResult + 1); |
| 292 | convertResult = MultiByteToWideChar(nCodePage, |
| 293 | 0, |
| 294 | path.c_str(), |
| 295 | (int)path.length(), |
| 296 | widePath.data(), |
| 297 | (int)widePath.size()); |
| 298 | |
| 299 | if (convertResult > 0) |
| 300 | return widePath; |
| 301 | } |
| 302 | |
| 303 | return {}; |
| 304 | #else |
| 305 | return path; |
| 306 | #endif |
| 307 | } |
| 308 | |
| 309 | std::string pathToConsoleString(const std::filesystem::path &path) |
| 310 | { |
no test coverage detected