MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / fix_path

Function fix_path

platform/windows/export/export_plugin.cpp:53–68  ·  view source on GitHub ↗

Converts long path to Windows UNC format.

Source from the content-addressed store, hash-verified

51
52// Converts long path to Windows UNC format.
53static 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

Callers 1

export_projectMethod · 0.70

Calls 11

is_relative_pathMethod · 0.80
path_joinMethod · 0.80
replace_charMethod · 0.80
trim_prefixMethod · 0.80
is_network_share_pathMethod · 0.80
begins_withMethod · 0.80
sizeMethod · 0.65
resize_uninitializedMethod · 0.45
ptrwMethod · 0.45
get_dataMethod · 0.45
simplify_pathMethod · 0.45

Tested by

no test coverage detected