/** * Get the remaining path from some tokens * * @param tokens the tokens * @param i the current location * @return the remaining path * @throws IllegalArgumentException for null tokens or i is out of range */ public static String getRemainingPath(List<String> tokens, int i) { if (tokens == null) { throw MESSAGES.nullArgument("tokens"); } return getRemainingPath(tokens, i, tokens.size()); }
/** * 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); }