int (@NotNull CharSequence path) { if (path.length() == 0) { return 0; } int end = lastSeparatorIndex(path, path.length() - 1); if (end == path.length() - 1 && end >= 1) { end = lastSeparatorIndex(path, end - 1); } if (end == -1 || end == 0) { return 0; } if (isWindowsUNCRoot(path, end)) { return 0; } // parent of '//host' is root char prev = path.charAt(end - 1); if (isSeparator(prev)) { end--; } return end; }