| 191 | } |
| 192 | |
| 193 | std::string AbsolutePath(const std::string &filepath) { |
| 194 | // clang-format off |
| 195 | |
| 196 | #ifdef FLATBUFFERS_NO_ABSOLUTE_PATH_RESOLUTION |
| 197 | return filepath; |
| 198 | #else |
| 199 | #ifdef _WIN32 |
| 200 | char abs_path[MAX_PATH]; |
| 201 | return GetFullPathNameA(filepath.c_str(), MAX_PATH, abs_path, nullptr) |
| 202 | #else |
| 203 | char *abs_path_temp = realpath(filepath.c_str(), nullptr); |
| 204 | bool success = abs_path_temp != nullptr; |
| 205 | std::string abs_path; |
| 206 | if(success) { |
| 207 | abs_path = abs_path_temp; |
| 208 | free(abs_path_temp); |
| 209 | } |
| 210 | return success |
| 211 | #endif |
| 212 | ? abs_path |
| 213 | : filepath; |
| 214 | #endif // FLATBUFFERS_NO_ABSOLUTE_PATH_RESOLUTION |
| 215 | // clang-format on |
| 216 | } |
| 217 | |
| 218 | // Locale-independent code. |
| 219 | #if defined(FLATBUFFERS_LOCALE_INDEPENDENT) && \ |