From 4731c7e50233e47a5e46531a1df7597e69417639 Mon Sep 17 00:00:00 2001 From: Chris Pickett Date: Tue, 5 Jan 2016 10:58:46 -0600 Subject: [PATCH 1/3] Fix build for platforms not supporting realpath Added a check for a preprocessor definition that can be set if the platform you're building for doesn't support any notion of absolute path resolution/realpath()/etc. --- include/flatbuffers/util.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/flatbuffers/util.h b/include/flatbuffers/util.h index ba73d67bd..d2d8cae8e 100644 --- a/include/flatbuffers/util.h +++ b/include/flatbuffers/util.h @@ -219,6 +219,9 @@ inline void EnsureDirExists(const std::string &filepath) { // Obtains the absolute path from any other path. // Returns the input path if the absolute path couldn't be resolved. inline std::string AbsolutePath(const std::string &filepath) { +#ifdef NO_ABSOLUTE_PATH_RESOLUTION + return filepath; +#else #ifdef _WIN32 char abs_path[MAX_PATH]; return GetFullPathNameA(filepath.c_str(), MAX_PATH, abs_path, nullptr) @@ -228,6 +231,7 @@ inline std::string AbsolutePath(const std::string &filepath) { #endif ? abs_path : filepath; +#endif // NO_ABSOLUTE_PATH_RESOLUTION } // To and from UTF-8 unicode conversion functions From b4fef31d8410afb2e5ee8d070ac777ebfb89b540 Mon Sep 17 00:00:00 2001 From: Chris Pickett Date: Wed, 6 Jan 2016 12:20:38 -0600 Subject: [PATCH 2/3] Made requested revisions for naming and spacing --- include/flatbuffers/util.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/include/flatbuffers/util.h b/include/flatbuffers/util.h index d2d8cae8e..2c3be68d3 100644 --- a/include/flatbuffers/util.h +++ b/include/flatbuffers/util.h @@ -219,19 +219,19 @@ inline void EnsureDirExists(const std::string &filepath) { // Obtains the absolute path from any other path. // Returns the input path if the absolute path couldn't be resolved. inline std::string AbsolutePath(const std::string &filepath) { -#ifdef NO_ABSOLUTE_PATH_RESOLUTION - return filepath; -#else - #ifdef _WIN32 - char abs_path[MAX_PATH]; - return GetFullPathNameA(filepath.c_str(), MAX_PATH, abs_path, nullptr) + #ifdef FLATBUFFERS_NO_ABSOLUTE_PATH_RESOLUTION + return filepath; #else - char abs_path[PATH_MAX]; - return realpath(filepath.c_str(), abs_path) - #endif - ? abs_path - : filepath; -#endif // NO_ABSOLUTE_PATH_RESOLUTION + #ifdef _WIN32 + char abs_path[MAX_PATH]; + return GetFullPathNameA(filepath.c_str(), MAX_PATH, abs_path, nullptr) + #else + char abs_path[PATH_MAX]; + return realpath(filepath.c_str(), abs_path) + #endif + ? abs_path + : filepath; + #endif // NO_ABSOLUTE_PATH_RESOLUTION } // To and from UTF-8 unicode conversion functions From a3363def52d4e7e57cef3b41b01c1d9249917fc1 Mon Sep 17 00:00:00 2001 From: Chris Pickett Date: Wed, 6 Jan 2016 12:21:17 -0600 Subject: [PATCH 3/3] Updated comment on endif for new name --- include/flatbuffers/util.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/flatbuffers/util.h b/include/flatbuffers/util.h index 2c3be68d3..b47d179c6 100644 --- a/include/flatbuffers/util.h +++ b/include/flatbuffers/util.h @@ -231,7 +231,7 @@ inline std::string AbsolutePath(const std::string &filepath) { #endif ? abs_path : filepath; - #endif // NO_ABSOLUTE_PATH_RESOLUTION + #endif // FLATBUFFERS_NO_ABSOLUTE_PATH_RESOLUTION } // To and from UTF-8 unicode conversion functions