Converts long path to Windows UNC format.
| 51 | |
| 52 | // Converts long path to Windows UNC format. |
| 53 | static String fix_path(const String &p_path) { |
| 54 | String path = p_path; |
| 55 | if (p_path.is_relative_path()) { |
| 56 | Char16String current_dir_name; |
| 57 | size_t str_len = GetCurrentDirectoryW(0, nullptr); |
| 58 | current_dir_name.resize_uninitialized(str_len + 1); |
| 59 | GetCurrentDirectoryW(current_dir_name.size(), (LPWSTR)current_dir_name.ptrw()); |
| 60 | path = String::utf16((const char16_t *)current_dir_name.get_data()).trim_prefix(R"(\\?\)").replace_char('\\', '/').path_join(path); |
| 61 | } |
| 62 | path = path.simplify_path(); |
| 63 | path = path.replace_char('/', '\\'); |
| 64 | if (path.size() >= MAX_PATH && !path.is_network_share_path() && !path.begins_with(R"(\\?\)")) { |
| 65 | path = R"(\\?\)" + path; |
| 66 | } |
| 67 | return path; |
| 68 | } |
| 69 | |
| 70 | #endif |
| 71 |
no test coverage detected