From 98321937c536739df43dd7d04ca8a3f71bd4acd3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zolt=C3=A1n=20Mizsei?= <zmizsei@extrowerk.com>
Date: Fri, 8 Dec 2017 18:14:31 +0100
Subject: [PATCH] Build fix

---
 COLLADABaseUtils/include/COLLADABUPlatform.h         |  2 +-
 DAEValidator/library/src/PathUtil.cpp                | 10 +++++++++-
 common/libBuffer/include/CommonFWriteBufferFlusher.h |  2 +-
 common/libBuffer/src/CommonFWriteBufferFlusher.cpp   |  6 +++---
 4 files changed, 14 insertions(+), 6 deletions(-)
 mode change 100755 => 100644 COLLADABaseUtils/include/COLLADABUPlatform.h
 mode change 100755 => 100644 DAEValidator/library/src/PathUtil.cpp
 mode change 100755 => 100644 common/libBuffer/include/CommonFWriteBufferFlusher.h
 mode change 100755 => 100644 common/libBuffer/src/CommonFWriteBufferFlusher.cpp

diff --git a/COLLADABaseUtils/include/COLLADABUPlatform.h b/COLLADABaseUtils/include/COLLADABUPlatform.h
old mode 100755
new mode 100644
index 097845b..0b7b46f
--- a/COLLADABaseUtils/include/COLLADABUPlatform.h
+++ b/COLLADABaseUtils/include/COLLADABUPlatform.h
@@ -23,7 +23,7 @@
 #  define COLLADABU_OS_WIN64
 #elif (defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__))
 #  define COLLADABU_OS_WIN32
-#elif defined(__linux__) || defined(__linux) || defined(__FreeBSD__)
+#elif defined(__linux__) || defined(__linux) || defined(__FreeBSD__) || defined(__HAIKU__)
 #  define COLLADABU_OS_LINUX
 #endif
 
diff --git a/DAEValidator/library/src/PathUtil.cpp b/DAEValidator/library/src/PathUtil.cpp
old mode 100755
new mode 100644
index fd2afae..529355c
--- a/DAEValidator/library/src/PathUtil.cpp
+++ b/DAEValidator/library/src/PathUtil.cpp
@@ -125,8 +125,16 @@ namespace opencollada
 			if ((dir = opendir(dirs.front().c_str())) != nullptr) {
 				while ((ent = readdir(dir)) != nullptr) {
 					string d_name = ent->d_name;
+					#ifdef __HAIKU__
+						struct stat sp;
+						stat(ent->d_name, &sp);
+					#endif
 					if (recursive &&
-						(ent->d_type & DT_DIR) &&
+						#ifndef __HAIKU__
+							(ent->d_type & DT_DIR) &&
+						#else
+							(S_ISDIR(sp.st_mode)) &&
+						#endif
 						d_name != "." &&
 						d_name != "..")
 					{
diff --git a/common/libBuffer/include/CommonFWriteBufferFlusher.h b/common/libBuffer/include/CommonFWriteBufferFlusher.h
old mode 100755
new mode 100644
index c7af45b..42ff162
--- a/common/libBuffer/include/CommonFWriteBufferFlusher.h
+++ b/common/libBuffer/include/CommonFWriteBufferFlusher.h
@@ -35,7 +35,7 @@ namespace std {
 #ifdef __GNUC__
 #   include <cstdlib> /* size_t */
 #   include <cstdio>  /* FILE */
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__HAIKU__)
 #include <stdint.h> /* int64_t */
 #endif
 #endif
diff --git a/common/libBuffer/src/CommonFWriteBufferFlusher.cpp b/common/libBuffer/src/CommonFWriteBufferFlusher.cpp
old mode 100755
new mode 100644
index 97480a1..2c1d2cb
--- a/common/libBuffer/src/CommonFWriteBufferFlusher.cpp
+++ b/common/libBuffer/src/CommonFWriteBufferFlusher.cpp
@@ -90,7 +90,7 @@ namespace Common
 		FilePosType currentPos = ftello64(mStream);
 #elif defined( _WIN32)
 		FilePosType currentPos = _ftelli64(mStream);
-#elif defined (__APPLE__) || defined(__FreeBSD__)
+#elif defined (__APPLE__) || defined(__FreeBSD__) || defined(__HAIKU__)
 		FilePosType currentPos = ftello(mStream);
 #else
 		FilePosType currentPos = ftello64(mStream);
@@ -115,7 +115,7 @@ namespace Common
   			return (fseeko64(mStream,0,SEEK_END) == 0);
 #elif defined( _WIN32)
 			return (_fseeki64(mStream, 0, SEEK_END) == 0);
-#elif defined (__APPLE__) || defined(__FreeBSD__)
+#elif defined (__APPLE__) || defined(__FreeBSD__) || defined(__HAIKU__)
 			return (fseeko(mStream, 0, SEEK_END) == 0);
 #else
 			return (fseeko64(mStream, 0, SEEK_END) == 0);
@@ -135,7 +135,7 @@ namespace Common
   				bool success = (fseeko64(mStream,pos,SEEK_SET) == 0);
 #elif defined( _WIN32)
 				bool success = (_fseeki64(mStream, pos, SEEK_SET) == 0);
-#elif defined (__APPLE__) || defined(__FreeBSD__)
+#elif defined (__APPLE__) || defined(__FreeBSD__) || defined(__HAIKU__)
 				bool success = (fseeko(mStream, pos, SEEK_SET) == 0);
 #else
 				bool success = (fseeko64(mStream, pos, SEEK_SET) == 0);
-- 
2.15.0

