| 91 | } |
| 92 | |
| 93 | String 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 | |
| 123 | String abspath(const String &p_path) { |
| 124 | if (p_path.is_absolute_path()) { |
no test coverage detected