Commit 6532bfce authored by Wouter van Oortmerssen's avatar Wouter van Oortmerssen

Merge pull request #3493 from parnic/support-platforms-without-realpath

Fix build for platforms not supporting realpath
parents 56f9b2d1 a3363def
...@@ -219,15 +219,19 @@ inline void EnsureDirExists(const std::string &filepath) { ...@@ -219,15 +219,19 @@ inline void EnsureDirExists(const std::string &filepath) {
// Obtains the absolute path from any other path. // Obtains the absolute path from any other path.
// Returns the input path if the absolute path couldn't be resolved. // Returns the input path if the absolute path couldn't be resolved.
inline std::string AbsolutePath(const std::string &filepath) { inline std::string AbsolutePath(const std::string &filepath) {
#ifdef _WIN32 #ifdef FLATBUFFERS_NO_ABSOLUTE_PATH_RESOLUTION
char abs_path[MAX_PATH]; return filepath;
return GetFullPathNameA(filepath.c_str(), MAX_PATH, abs_path, nullptr)
#else #else
char abs_path[PATH_MAX]; #ifdef _WIN32
return realpath(filepath.c_str(), abs_path) char abs_path[MAX_PATH];
#endif return GetFullPathNameA(filepath.c_str(), MAX_PATH, abs_path, nullptr)
? abs_path #else
: filepath; char abs_path[PATH_MAX];
return realpath(filepath.c_str(), abs_path)
#endif
? abs_path
: filepath;
#endif // FLATBUFFERS_NO_ABSOLUTE_PATH_RESOLUTION
} }
// To and from UTF-8 unicode conversion functions // To and from UTF-8 unicode conversion functions
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment