< prev index next >

src/hotspot/os/bsd/os_bsd.inline.hpp

Print this page

        

@@ -32,15 +32,48 @@
 #include <unistd.h>
 #include <sys/socket.h>
 #include <poll.h>
 #include <netdb.h>
 
-// File names are case-insensitive on windows only
+#ifdef __APPLE__
+
+#include <unistd.h>
+#include <strings.h>
+#include <xlocale.h>
+
+// File names could be case-insensitive on Mac OS X,
+// depending on the filesystem's capabilities
+static bool is_filesystem_case_insensitive(const char* path) {
+  if (path[0] != '/') {
+    // The path is relative, so use the current working directory
+    char cwd[PATH_MAX];
+    os::get_current_directory(cwd, PATH_MAX);
+    return (pathconf(cwd, _PC_CASE_SENSITIVE) != 1);
+  } else {
+    // The path is absolute, so use it
+    return (pathconf(path, _PC_CASE_SENSITIVE) != 1);
+  }
+}
+
+inline int os::file_name_strncmp(const char* s1, const char* s2, size_t num) {
+  int result = strncmp(s1, s2, num);
+  if ((result != 0) && (strlen(s1) == strlen(s2))) {
+    if (is_filesystem_case_insensitive(s1)) {
+      result = strncasecmp(s1, s2, num);
+    }
+  }
+  return result;
+}
+
+#else
+
 inline int os::file_name_strncmp(const char* s1, const char* s2, size_t num) {
   return strncmp(s1, s2, num);
 }
 
+#endif // __APPLE__
+
 inline bool os::obsolete_option(const JavaVMOption *option) {
   return false;
 }
 
 inline bool os::uses_stack_guard_pages() {
< prev index next >