@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 oldLength = item.stat.getLen(); if(newLength > oldLength) { throw new IllegalArgumentException( "Cannot truncate to a larger file size. Current size: " + oldLength + ", truncate size: " + newLength + "."); } if(item.fs.truncate(item.path, newLength)) { out.println("Truncated " + item + " to length: " + newLength); } else if(waitOpt) { waitList.add(item); } else { out.println("Truncating " + item + " to length: " + newLength + ". " + "Wait for block recovery to complete before further updating this " + "file."); } }
@Override protected void processPath(PathData item) throws IOException { if (item.stat.isDirectory()) { throw new PathIsDirectoryException(item.toString()); } FileChecksum checksum = item.fs.getFileChecksum(item.path); if (checksum == null) { out.printf("%s\tNONE\t%n", item.toString()); } else { String checksumString = StringUtils.byteToHexString( checksum.getBytes(), 0, checksum.getLength()); out.printf("%s\t%s\t%s%n", item.toString(), checksum.getAlgorithmName(), checksumString); } }
@Override protected void processOptions(LinkedList<String> args) throws IOException { try { CommandFormat cf = new CommandFormat(2, Integer.MAX_VALUE, "nl", "skip-empty-file"); cf.parse(args); delimiter = cf.getOpt("nl") ? "\n" : null; skipEmptyFileDelimiter = cf.getOpt("skip-empty-file"); dst = new PathData(new URI(args.removeLast()), getConf()); if (dst.exists && dst.stat.isDirectory()) { throw new PathIsDirectoryException(dst.toString()); } srcs = new LinkedList<PathData>(); } catch (URISyntaxException e) { throw new IOException("unexpected URISyntaxException", e); } }
@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); } }
@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)) { return; } if (!item.fs.delete(item.path, deleteDirs)) { throw new PathIOException(item.toString()); } out.println("Deleted " + item); }
@Override protected void processOptions(LinkedList<String> args) throws IOException { try { CommandFormat cf = new CommandFormat(2, Integer.MAX_VALUE, "nl"); cf.parse(args); delimiter = cf.getOpt("nl") ? "\n" : null; dst = new PathData(new URI(args.removeLast()), getConf()); if (dst.exists && dst.stat.isDirectory()) { throw new PathIsDirectoryException(dst.toString()); } srcs = new LinkedList<PathData>(); } catch (URISyntaxException e) { throw new IOException("unexpected URISyntaxException", e); } }
@Override protected void processPath(PathData item) throws IOException { if (item.stat.isDirectory()) { throw new PathIsDirectoryException(item.toString()); } FileChecksum checksum = item.fs.getFileChecksum(item.path); if (checksum == null) { out.printf("%s\tNONE\t\n", item.toString()); } else { String checksumString = StringUtils.byteToHexString( checksum.getBytes(), 0, checksum.getLength()); out.printf("%s\t%s\t%s\n", item.toString(), checksum.getAlgorithmName(), checksumString); } }