if (file.length() < SHA256_FILE_USE_SHELL_THRESHHOLD) return sha256_file_java(file);
result = exec(new CommandLine("sha256sum").addArgument(abs(file), false));
result = exec(shaCommand().addArgument(abs(file), false));
if (result.isZeroExitStatus()) return split(result.getStdout(), " ").get(0);
} catch (Exception e) {
@@ -80,6 +81,14 @@ public class ShaUtil {
return die("sha256sum_file: sha256sum "+abs(file)+" exited with status "+result.getExitStatus()+", stderr="+result.getStderr()+", exception="+result.getExceptionString());
}
private static CommandLine shaCommand() {
if (IS_OS_MAC) {
return new CommandLine("shasum").addArgument("-a").addArgument("256");
} else {
return new CommandLine("sha256sum");
}
}
public static String sha256_file_java(File file) {
try {
@Cleanup final InputStream input = new FileInputStream(file);
+ 1- 1
src/main/java/org/cobbzilla/util/system/CommandShell.javaVoir le fichier
@@ -258,7 +258,7 @@ public class CommandShell {
}
}
public static final long totalSystemMemory() { return HARDWARE.getMemory().getTotal(); }
public static long totalSystemMemory() { return HARDWARE.getMemory().getTotal(); }
public static String hostname () { return toString("hostname"); }
public static String domainname() { return toString("hostname -d"); }