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

Function cwd

modules/mono/utils/path_utils.cpp:93–121  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

91}
92
93String cwd() {
94#ifdef WINDOWS_ENABLED
95 const DWORD expected_size = ::GetCurrentDirectoryW(0, nullptr);
96
97 Char16String buffer;
98 buffer.resize_uninitialized((int)expected_size);
99 if (::GetCurrentDirectoryW(expected_size, (wchar_t *)buffer.ptrw()) == 0) {
100 return ".";
101 }
102
103 String result = String::utf16(buffer.ptr());
104 if (result.is_empty()) {
105 return ".";
106 }
107 return result.simplify_path();
108#else
109 char buffer[PATH_MAX];
110 if (::getcwd(buffer, sizeof(buffer)) == nullptr) {
111 return ".";
112 }
113
114 String result;
115 if (result.append_utf8(buffer) != OK) {
116 return ".";
117 }
118
119 return result.simplify_path();
120#endif
121}
122
123String abspath(const String &p_path) {
124 if (p_path.is_absolute_path()) {

Callers 1

abspathFunction · 0.85

Calls 6

resize_uninitializedMethod · 0.45
ptrwMethod · 0.45
ptrMethod · 0.45
is_emptyMethod · 0.45
simplify_pathMethod · 0.45
append_utf8Method · 0.45

Tested by

no test coverage detected