|
@@ -175,7 +175,7 @@ class Display extends FsCommand {
|
|
|
|
|
|
public static class Checksum extends Display {
|
|
public static class Checksum extends Display {
|
|
public static final String NAME = "checksum";
|
|
public static final String NAME = "checksum";
|
|
- public static final String USAGE = "<src> ...";
|
|
|
|
|
|
+ public static final String USAGE = "[-v] <src> ...";
|
|
public static final String DESCRIPTION =
|
|
public static final String DESCRIPTION =
|
|
"Dump checksum information for files that match the file " +
|
|
"Dump checksum information for files that match the file " +
|
|
"pattern <src> to stdout. Note that this requires a round-trip " +
|
|
"pattern <src> to stdout. Note that this requires a round-trip " +
|
|
@@ -184,6 +184,16 @@ class Display extends FsCommand {
|
|
"file depends on its content, block size and the checksum " +
|
|
"file depends on its content, block size and the checksum " +
|
|
"algorithm and parameters used for creating the file.";
|
|
"algorithm and parameters used for creating the file.";
|
|
|
|
|
|
|
|
+ private boolean displayBlockSize;
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ protected void processOptions(LinkedList<String> args)
|
|
|
|
+ throws IOException {
|
|
|
|
+ CommandFormat cf = new CommandFormat(1, Integer.MAX_VALUE, "v");
|
|
|
|
+ cf.parse(args);
|
|
|
|
+ displayBlockSize = cf.getOpt("v");
|
|
|
|
+ }
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
protected void processPath(PathData item) throws IOException {
|
|
protected void processPath(PathData item) throws IOException {
|
|
if (item.stat.isDirectory()) {
|
|
if (item.stat.isDirectory()) {
|
|
@@ -191,14 +201,15 @@ class Display extends FsCommand {
|
|
}
|
|
}
|
|
|
|
|
|
FileChecksum checksum = item.fs.getFileChecksum(item.path);
|
|
FileChecksum checksum = item.fs.getFileChecksum(item.path);
|
|
- if (checksum == null) {
|
|
|
|
- out.printf("%s\tNONE\t%n", item.toString());
|
|
|
|
|
|
+ String outputChecksum = checksum == null ? "NONE" :
|
|
|
|
+ String.format("%s\t%s", checksum.getAlgorithmName(), StringUtils
|
|
|
|
+ .byteToHexString(checksum.getBytes(), 0, checksum.getLength()));
|
|
|
|
+ if (displayBlockSize) {
|
|
|
|
+ FileStatus fileStatus = item.fs.getFileStatus(item.path);
|
|
|
|
+ out.printf("%s\t%s\tBlockSize=%s%n", item.toString(), outputChecksum,
|
|
|
|
+ fileStatus != null ? fileStatus.getBlockSize() : "NONE");
|
|
} else {
|
|
} else {
|
|
- String checksumString = StringUtils.byteToHexString(
|
|
|
|
- checksum.getBytes(), 0, checksum.getLength());
|
|
|
|
- out.printf("%s\t%s\t%s%n",
|
|
|
|
- item.toString(), checksum.getAlgorithmName(),
|
|
|
|
- checksumString);
|
|
|
|
|
|
+ out.printf("%s\t%s%n", item.toString(), outputChecksum);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|