/** * Apply any . or .. paths in the pathTokens parameter, returning the minimal token list. * * @param pathTokens the path tokens * @return the simple path tokens * @throws IllegalArgumentException if reverse path goes over the top path */ public static List<String> applySpecialPaths(List<String> pathTokens) throws IllegalArgumentException { final ArrayList<String> newTokens = new ArrayList<String>(); for (String pathToken : pathTokens) { if (isCurrentToken(pathToken)) { continue; } else if (isReverseToken(pathToken)) { final int size = newTokens.size(); if (size == 0) { throw VFSMessages.MESSAGES.onRootPath(); } newTokens.remove(size - 1); } else { newTokens.add(pathToken); } } return newTokens; }
while (it.hasNext()) { String token = it.next(); if (PathTokenizer.isCurrentToken(token) || PathTokenizer.isReverseToken(token)) {
while (it.hasNext()) { String token = it.next(); if (PathTokenizer.isCurrentToken(token) || PathTokenizer.isReverseToken(token)) {
/** * Apply any . or .. paths in the path param. * * @param path the path * @return simple path, containing no . or .. paths */ public static String applySpecialPaths(String path) throws IllegalArgumentException { List<String> tokens = getTokens(path); if (tokens == null) { return null; } int i = 0; for (int j = 0; j < tokens.size(); j++) { String token = tokens.get(j); if (isCurrentToken(token)) { continue; } else if (isReverseToken(token)) { i--; } else { tokens.set(i++, token); } if (i < 0) { throw VFSMessages.MESSAGES.onRootPath(); } } return getRemainingPath(tokens, 0, i); }
while (it.hasNext()) { String token = it.next(); if (PathTokenizer.isCurrentToken(token) || PathTokenizer.isReverseToken(token)) {
while (it.hasNext()) { String token = it.next(); if (PathTokenizer.isCurrentToken(token) || PathTokenizer.isReverseToken(token)) {
while (it.hasNext()) { String token = it.next(); if (PathTokenizer.isCurrentToken(token) || PathTokenizer.isReverseToken(token)) {
/** * Get a child virtual file. The child may or may not exist in the virtual filesystem. * * @param path the path * @return the child * @throws IllegalArgumentException if the path is null */ public VirtualFile getChild(String path) { if (path == null) { throw VFSMessages.MESSAGES.nullArgument("path"); } final List<String> pathParts = PathTokenizer.getTokens(path); VirtualFile current = this; for (String part : pathParts) { if (PathTokenizer.isReverseToken(part)) { final VirtualFile parent = current.parent; current = parent == null ? current : parent; } else if (PathTokenizer.isCurrentToken(part) == false) { current = new VirtualFile(part, current); } } return current; }