PathUtils { public static boolean pathEquals(String path1, String path2, String separator) { if(path1==null) return path2==null; if(path2==null) return path1==null; if(path1.equals(path2)) return true; int len1 = path1.length(); int len2 = path2.length(); int separatorLen = separator.length(); if(Math.abs(len1-len2)==separatorLen && (len1>len2 ? path1.startsWith(path2) : path2.startsWith(path1))) { String diff = len1>len2 ? path1.substring(len1-separatorLen) : path2.substring(len2-separatorLen); return separator.equals(diff); } return false; }  static ResolvedDestination resolveDestination(String destPath, AbstractFile baseFolder); static String removeLeadingSeparator(String path); static String removeLeadingSeparator(String path, String separator); static String removeTrailingSeparator(String path); static String removeTrailingSeparator(String path, String separator); static boolean pathEquals(String path1, String path2, String separator); static int getPathHashCode(String path, String separator); static String removeLeadingFragments(String path, String separator, int nbFragments); static int getDepth(String path, String separator);  }
@Test public void testPathEquals() { assert PathUtils.pathEquals("/home/", "/home/", "/"); assert PathUtils.pathEquals("/home", "/home", "/"); assert PathUtils.pathEquals("/home/", "/home/", "\\"); assert PathUtils.pathEquals("/home/", "/home", "/"); assert PathUtils.pathEquals("/home", "/home/", "/"); assert PathUtils.pathEquals("C:\\home\\", "C:\\home\\", "\\"); assert PathUtils.pathEquals("C:\\home", "C:\\home", "\\"); assert PathUtils.pathEquals("C:\\home\\", "C:\\home\\", "/"); assert PathUtils.pathEquals("C:\\home\\", "C:\\home", "\\"); assert PathUtils.pathEquals("C:\\home", "C:\\home\\", "\\"); assert PathUtils.pathEquals("--home--", "--home--", "--"); assert PathUtils.pathEquals("--home", "--home", "--"); assert PathUtils.pathEquals("--home--", "--home--", "/"); assert PathUtils.pathEquals("--home--", "--home", "--"); assert PathUtils.pathEquals("--home", "--home--", "--"); assert !(PathUtils.pathEquals("/", "/home", "/")); assert !(PathUtils.pathEquals("/home", "/home/", "\\")); assert !(PathUtils.pathEquals("/home/", "/home", "\\")); assert !(PathUtils.pathEquals("C:\\", "C:\\home", "\\")); assert !(PathUtils.pathEquals("C:\\home", "C:\\home\\", "/")); assert !(PathUtils.pathEquals("C:\\home\\", "C:\\home", "/")); assert !(PathUtils.pathEquals("--", "--home", "--")); assert !(PathUtils.pathEquals("--home", "--home--", "/")); assert !(PathUtils.pathEquals("--home--", "--home", "/")); }