boolean (@NotNull String path, @NotNull String prefix) { int pathLength = path.length(); int prefixLength = prefix.length(); if (prefixLength == 0) return true; if (prefixLength > pathLength) return false; boolean ignoreCase = !SystemInfoRt.isFileSystemCaseSensitive; for (int pos = 0; pos < pathLength && pos < prefixLength; pos++) { char ch1 = path.charAt(pos); char ch2 = prefix.charAt(pos); if (ch1 == ch2) continue; if (ch1 == '/') { if (ch2 == '\\') continue; return false; } else if (ch1 == '\\') { if (ch2 == '/') continue; return false; } else if (ch2 == '/' || ch2 == '\\') { return false; } if (StringUtil.compare(ch1, ch2, ignoreCase) != 0) { return false; } } if (pathLength == prefixLength) { return true; } char lastPrefixChar = prefix.charAt(prefixLength - 1); int slashOrSeparatorIdx = prefixLength; if (lastPrefixChar == '/' || lastPrefixChar == '\\') { slashOrSeparatorIdx = prefixLength - 1; } char next = path.charAt(slashOrSeparatorIdx); return next == '/' || next == '\\'; }