/** {@inheritDoc} */ @Override protected void processPathArgument(PathData item) throws IOException { if(item.stat.isSymlink() && (getOptions().isFollowArgLink() || getOptions().isFollowLink())) { item = new PathData(item.stat.getSymlink().toString(), getConf()); } super.processPathArgument(item); } /** Gets a named expression from the factory. */
@Override protected void recursePath(PathData item) throws IOException { if(item.stat.isSymlink() && getOptions().isFollowLink()) { PathData linkedItem = new PathData(item.stat.getSymlink().toString(), getConf()); if(linksFollowed.contains(item)) { getOptions().getErr().println("Infinite loop ignored: " + item.toString() + " -> " + linkedItem.toString()); return; } linksFollowed.add(item); item = linkedItem; } if(item.stat.isDirectory()) { super.recursePath(item); } }
/** {@inheritDoc} */ @Override protected void processArguments(LinkedList<PathData> args) throws IOException { Expression expr = getRootExpression(); expr.initialise(getOptions()); super.processArguments(args); expr.finish(); }
/** {@inheritDoc} */ @Override protected void processPaths(PathData parent, PathData ... items) throws IOException { if(parent == null) { // processing a command line argument so clear the links followed linksFollowed.clear(); } Expression expr = getRootExpression(); for (PathData item : items) { try { if(getOptions().isDepth()) { recursePath(item); expr.apply(item); } else if (expr.apply(item).isDescend()) { recursePath(item); } } catch (IOException e) { displayError(e); } } }