PathUtils { public static String removeLeadingSeparator(String path) { char firstChar; if(path.length()>0 && ((firstChar=path.charAt(0))=='/' || firstChar=='\\')) return path.substring(1); return path; }  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 testRemoveLeadingSeparator() { assert PathUtils.removeLeadingSeparator("/home/", "/").equals("home/"); assert PathUtils.removeLeadingSeparator("/home/maxence", "/").equals("home/maxence"); assert PathUtils.removeLeadingSeparator("home/", "/").equals("home/"); assert PathUtils.removeLeadingSeparator("/home/", "\\").equals("/home/"); assert PathUtils.removeLeadingSeparator("/", "/").equals(""); assert PathUtils.removeLeadingSeparator("C:\\home\\", "\\").equals("C:\\home\\"); assert PathUtils.removeLeadingSeparator("C:\\home\\", "/").equals("C:\\home\\"); assert PathUtils.removeLeadingSeparator("--home--", "--").equals("home--"); assert PathUtils.removeLeadingSeparator("--home--maxence", "--").equals("home--maxence"); assert PathUtils.removeLeadingSeparator("home--", "--").equals("home--"); assert PathUtils.removeLeadingSeparator("--home--", "/").equals("--home--"); assert PathUtils.removeLeadingSeparator("--", "--").equals(""); }