< prev index next >
src/hotspot/os/bsd/os_bsd.inline.hpp
Print this page
@@ -32,15 +32,54 @@
#include <unistd.h>
#include <sys/socket.h>
#include <poll.h>
#include <netdb.h>
-// File names are case-insensitive on windows only
+#ifdef __APPLE__
+
+#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) {
+ char resolved[PATH_MAX] = {'\0'};
+ if (path[0] != '/') {
+ // The path is relative, so find the current working directory
+ os::get_current_directory(resolved, PATH_MAX);
+ // Start resolving full path
+ int remaining = PATH_MAX - strlen(resolved) - 1;
+ if (remaining > 0) {
+ strncat(resolved, "/", (size_t)remaining);
+ }
+ }
+ // Resolve full path
+ int remaining = PATH_MAX - strlen(resolved) - 1;
+ if (remaining > 0) {
+ strncat(resolved, path, (size_t)remaining);
+ }
+ return (pathconf(resolved, _PC_CASE_SENSITIVE) == 0);
+}
+
+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 >