@Override protected void processPath(PathData item) throws IOException { if (!item.stat.isDirectory()) { throw new PathIsNotDirectoryException(item.toString()); } }
@Override protected void processPath(PathData item) throws IOException { if (!item.stat.isDirectory()) { throw new PathIsNotDirectoryException(item.toString()); } }
@Override protected void processPath(PathData item) throws IOException { if (!item.stat.isDirectory()) { throw new PathIsNotDirectoryException(item.toString()); } }
/** * Provides a hook for handling paths that don't exist. By default it * will throw an exception. Primarily overriden by commands that create * paths such as mkdir or touch. * @param item the {@link PathData} that doesn't exist * @throws FileNotFoundException if arg is a path and it doesn't exist * @throws IOException if anything else goes wrong... */ protected void processNonexistentPath(PathData item) throws IOException { throw new PathNotFoundException(item.toString()); }
@Override protected void processPath(PathData item) throws IOException { if (!item.stat.isDirectory()) { throw new PathIsNotDirectoryException(item.toString()); } if (item.fs.listStatus(item.path).length == 0) { if (!item.fs.delete(item.path, false)) { throw new PathIOException(item.toString()); } } else if (!ignoreNonEmpty) { throw new PathIsNotEmptyDirectoryException(item.toString()); } } }
@Override protected void processPath(PathData src, PathData target) throws IOException { // unlike copy, don't merge existing dirs during move if (target.exists && target.stat.isDirectory()) { throw new PathExistsException(target.toString()); } super.processPath(src, target); }
@Override protected void processPath(PathData item) throws IOException { if (item.stat.isDirectory()) { throw new PathIsDirectoryException(item.toString()); } dumpToOffset(item); }
@Override protected void processArguments(LinkedList<PathData> args) throws IOException { // NOTE: this logic should be better, mimics previous implementation if (args.size() == 1 && args.get(0).toString().equals("-")) { copyStreamToTarget(System.in, getTargetPath(args.get(0))); return; } super.processArguments(args); } }
@Override protected void processPath(PathData item) throws IOException { if (item.stat.isDirectory()) { throw new PathIsDirectoryException(item.toString()); } touch(item); }
@Override protected void postProcessPath(PathData src) throws IOException { if (!src.fs.delete(src.path, false)) { // we have no way to know the actual error... PathIOException e = new PathIOException(src.toString()); e.setOperation("remove"); throw e; } } }
@Override public Result apply(PathData item, int depth) throws IOException { getOptions().getOut().print(item.toString() + suffix); return Result.PASS; }
@Override protected void processPath(PathData item) throws IOException { if (item.stat.isDirectory() && !deleteDirs) { throw new PathIsDirectoryException(item.toString()); } // TODO: if the user wants the trash to be used but there is any // problem (ie. creating the trash dir, moving the item to be deleted, // etc), then the path will just be deleted because moveToTrash returns // false and it falls thru to fs.delete. this doesn't seem right if (moveToTrash(item) || !canBeSafelyDeleted(item)) { return; } if (!item.fs.delete(item.path, deleteDirs)) { throw new PathIOException(item.toString()); } out.println("Deleted " + item); }
@Override protected void processPath(PathData item) throws IOException { if (item.stat.isDirectory()) { throw new PathIsDirectoryException(item.toString()); } long offset = dumpFromOffset(item, startingOffset); while (follow) { try { Thread.sleep(followDelay); } catch (InterruptedException e) { break; } offset = dumpFromOffset(item, offset); } }
/** * Updates the paths's file status * @return the updated FileStatus * @throws IOException if anything goes wrong... */ public FileStatus refreshStatus() throws IOException { FileStatus status = null; try { status = lookupStat(fs, toString(), false); } finally { // always set the status. the caller must get the correct result // if it catches the exception and later interrogates the status setStat(status); } return status; }
@Override protected void processNonexistentPath(PathData item) throws IOException { if (!item.parentExists()) { throw new PathNotFoundException(item.toString()) .withFullyQualifiedPath(item.path.toUri().toString()); } touchz(item); }
@Override protected void processNonexistentPath(PathData item) throws IOException { if (!item.parentExists()) { throw new PathNotFoundException(item.toString()) .withFullyQualifiedPath(item.path.toUri().toString()); } touch(item); }
@Override protected void processPath(PathData item) throws IOException { if (item.stat.isDirectory()) { throw new PathIsDirectoryException(item.toString()); } item.fs.setVerifyChecksum(verifyChecksum); printToStdout(getInputStream(item)); }
private void copyFile(PathData src, PathData target) throws IOException { if (isPathRecursable(src)) { throw new PathIsDirectoryException(src.toString()); } super.copyFileToTarget(src, target); }