From a803c327336e10709333c8c87db86cb8ae2c0cb8 Mon Sep 17 00:00:00 2001
From: Ardekantur <greystone@ardekantur.com>
Date: Thu, 3 Jun 2010 19:40:23 -0400
Subject: [PATCH] Updated to work with latest changes upstream

---
 CMakeLists.txt     |  2 +-
 esm/esm_reader.hpp |  4 ++++
 plugins.cfg.linux  |  2 +-
 tools/fileops.cpp  | 22 +++++++++++++++++-----
 4 files changed, 23 insertions(+), 7 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7c8a4b104..9f6327315 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -25,7 +25,7 @@ endif (WIN32)
 find_package(OGRE REQUIRED)
 find_package(BOOST REQUIRED)
 include_directories("." ${OGRE_INCLUDE_DIR} ${Boost_INCLUDE_DIR} ${PLATFORM_INCLUDE_DIR})
-link_directories(${OGRE_LIB_DIR})
+link_directories(${Boost_LIBRARY_DIRS} ${OGRE_LIB_DIR})
 
 # Main executable
 add_executable(openmw ${BSA} ${TOOLS} ${OGRE} ${GAME})
diff --git a/esm/esm_reader.hpp b/esm/esm_reader.hpp
index 193c4654b..63374b11b 100644
--- a/esm/esm_reader.hpp
+++ b/esm/esm_reader.hpp
@@ -14,12 +14,16 @@
 #include "../mangle/tools/str_exception.hpp"
 #include "../tools/stringops.hpp"
 
+#ifdef __APPLE__
+// need our own implementation of strnlen
 static size_t strnlen(const char *s, size_t n)
 {
   const char *p = (const char *)memchr(s, 0, n);
   return(p ? p-s : n);
 }
 
+#endif
+
 namespace ESM {
 
 enum Version
diff --git a/plugins.cfg.linux b/plugins.cfg.linux
index 51b57b1e5..e1d4dbc80 100644
--- a/plugins.cfg.linux
+++ b/plugins.cfg.linux
@@ -1,7 +1,7 @@
 # Defines plugins to load
 
 # Define plugin folder
-PluginFolder=/usr/local/lib/OGRE
+PluginFolder=/usr/local/lib/OGRE/
 
 # Define plugins
 Plugin=RenderSystem_GL
diff --git a/tools/fileops.cpp b/tools/fileops.cpp
index 10436e719..0e8115662 100644
--- a/tools/fileops.cpp
+++ b/tools/fileops.cpp
@@ -11,10 +11,7 @@ bool isFile(const char *name)
   return (stat != 0xFFFFFFFF &&
           (stat & FILE_ATTRIBUTE_DIRECTORY) == 0);
 }
-#endif // _WIN32
-
-// Linux implementations
-#ifdef __linux__
+#elif __linux__ // Linux implementations
 
 #include <sys/stat.h>
 #include <unistd.h>
@@ -29,4 +26,19 @@ bool isFile(const char *name)
   if(stat(name, &st)) return false;
   return S_ISREG(st.st_mode);
 }
-#endif // __linux__
+
+#elif __APPLE__ // Darwin implementations
+#include <sys/stat.h>
+#include <unistd.h>
+
+bool isFile(const char *name)
+{
+  // Does the file exist?
+  if(access(name,0) != 0)
+    return false;
+
+  struct stat st;
+  if(stat(name, &st)) return false;
+  return S_ISREG(st.st_mode);
+}
+#endif