MCPcopy Create free account
hub / github.com/assimp/assimp / MakeAbsolutePath

Function MakeAbsolutePath

code/Common/DefaultIOSystem.cpp:168–189  ·  view source on GitHub ↗

------------------------------------------------------------------------------------------------ Convert a relative path into an absolute path

Source from the content-addressed store, hash-verified

166// ------------------------------------------------------------------------------------------------
167// Convert a relative path into an absolute path
168inline static std::string MakeAbsolutePath(const char *in) {
169 ai_assert(in);
170 std::string out;
171#ifdef _WIN32
172 wchar_t *ret = ::_wfullpath(nullptr, Utf8ToWide(in).c_str(), 0);
173 if (ret) {
174 out = WideToUtf8(ret);
175 free(ret);
176 }
177#else
178 char *ret = realpath(in, nullptr);
179 if (ret) {
180 out = ret;
181 free(ret);
182 }
183#endif
184 else {
185 // preserve the input path, maybe someone else is able to fix
186 // the path before it is accessed (e.g. our file system filter)
187 ASSIMP_LOG_WARN("Invalid path: ", std::string(in));
188 out = in;
189 }
190 return out;
191}
192

Callers 1

ComparePathsMethod · 0.85

Calls 2

Utf8ToWideFunction · 0.85
WideToUtf8Function · 0.85

Tested by

no test coverage detected