/** * Breaks a path up into a Vector of path elements, tokenizing on * * @param path Path to tokenize. Must not be <code>null</code>. * @param separator the separator against which to tokenize. * * @return a Vector of path elements from the tokenized path * @since Ant 1.6 */ public static Vector tokenizePath (String path, String separator) { Vector ret = new Vector(); if (FileUtil.isAbsolutePath(path)) { String[] s = FileUtil.dissect(path); ret.add(s[0]); path = s[1]; } StringTokenizer st = new StringTokenizer(path, separator); while (st.hasMoreTokens()) { ret.addElement(st.nextToken()); } return ret; }
if (!isAbsolutePath(path)) { throw new RuntimeException(path + " is not an absolute path");
if (FileUtil.isAbsolutePath(path)) { String[] s = FileUtil.dissect(path); root = s[0];
/** * From <code>base</code> traverse the filesystem in order to find * a file that matches the given name. * * @param base base File (dir). * @param path file path. * @param cs whether to scan case-sensitively. * @return File object that points to the file in question or null. * * @since Ant 1.6.3 */ private File findFile(File base, String path, boolean cs) { if (FileUtil.isAbsolutePath(path)) { if (base == null) { String[] s = FileUtil.dissect(path); base = new File(s[0]); path = s[1]; } else { File f = FileUtil.normalize(path); String s = FileUtil.removeLeadingPath(base, f); if (s.equals(f.getAbsolutePath())) { //removing base from path yields no change; path not child of base return null; } path = s; } } return findFile(base, SelectorUtils.tokenizePath(path), cs); }
@Test @RunIf(value = EnhancedOSChecker.class, arguments = {EnhancedOSChecker.WINDOWS}) public void shouldReturnFalseForInvalidWindowsUNCFilePath() { assertThat(FileUtil.isAbsolutePath("\\\\host\\"), is(false)); assertThat(FileUtil.isAbsolutePath("\\\\host"), is(false)); }
@Test @RunIf(value = EnhancedOSChecker.class, arguments = {EnhancedOSChecker.WINDOWS}) public void shouldReturnTrueForValidWindowsUNCFilePath() { assertThat(FileUtil.isAbsolutePath("\\\\host\\share"), is(true)); assertThat(FileUtil.isAbsolutePath("\\\\host\\share\\dir"), is(true)); }
if (FileUtil.isAbsolutePath(includes[i])) { String currentelement = (String) entry.getKey(); if (basedir == null && !FileUtil.isAbsolutePath(currentelement)) { continue;