1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-29 12:07:46 +00:00

Made cksum to return an error if the algorithm blake2b is used on a directory

This commit is contained in:
Atomei Alexandru Constantin 2024-01-07 23:39:33 +02:00
parent f1499d0e79
commit 288ad97878

View file

@ -169,6 +169,13 @@ where
(ALGORITHM_OPTIONS_CRC, true) => println!("{sum} {sz}"),
(ALGORITHM_OPTIONS_CRC, false) => println!("{sum} {sz} {}", filename.display()),
(ALGORITHM_OPTIONS_BLAKE2B, _) if !options.untagged => {
if filename.is_dir() {
return Err(io::Error::new(
io::ErrorKind::InvalidInput,
format!("{}: Is a directory", filename.display()),
)
.into());
}
if let Some(length) = options.length {
// Multiply by 8 here, as we want to print the length in bits.
println!("BLAKE2b-{} ({}) = {sum}", length * 8, filename.display());