update man, implement zero

This commit is contained in:
Bryson Steck 2025-09-01 10:45:48 -06:00
commit af061cc7b5
Signed by: bryson
SSH key fingerprint: SHA256:XpKABw/nP4z8UVaH+weLaBnEOD86+cVwif+QjuYLGT4
4 changed files with 17 additions and 4 deletions

View file

@ -23,13 +23,15 @@ When conditions are suitable, being able to hash multiple files in parallel can
# OPTIONS
With no FILE(s) specified, or when FILE is a dash (-), picca will read from standard input.
With no _FILE_(s) specified, or when _FILE_ is a dash (-), picca will read from standard input.
If **-c** is specified, _FILE_(s) will act as a filter for the checksums found in _CHECK_. For more information, see **-c** below.
**-a, ––algorithm** _ALGORITHM_
: Specify the algorithm for hashing. The default value is sha256. A list of supported algorithms can be found in the **ALGORITHMS** section.
**-c, ––check** _CHECK_
: Read checksums from the specified file and verify them. This argument can be specified multiple times to read checksums from multiple files.
: Read checksums from the specified file and verify them. This argument can be specified multiple times to read checksums from multiple files. When **-c** is specified, _FILE_(s) acts as a filter for files found in _CHECK_, effectively only verifying the checksums of those files. If _FILE_(s) does not match any files in _CHECK_, the program will exit.
**-d, ––debug**
: Enable debug output for troubleshooting purposes. Messages output to standard error.

View file

@ -19,6 +19,7 @@ pub mod macros;
struct ThreadInfo {
debug: bool,
quiet: bool,
zero: bool,
thread_id: usize,
filenames: Arc<Mutex<VecDeque<PathBuf>>>,
#[cfg(feature = "all")]
@ -97,7 +98,11 @@ fn hash(info: ThreadInfo) -> Result<(), String> {
},
None => {
if !info.quiet {
println!("{} {}", res, filename.as_path().display());
if info.zero {
print!("{} {}\0", res, filename.as_path().display());
} else {
println!("{} {}", res, filename.as_path().display());
}
}
},
}
@ -176,6 +181,7 @@ pub fn verify(
#[cfg(feature = "all")] algorithm: String,
debug: bool,
quiet: bool,
zero: bool,
checksum_files: Vec<PathBuf>,
filter: Vec<PathBuf>,
#[cfg(feature = "single")] hash_function: fn(Option<File>, Option<String>) -> String,
@ -217,6 +223,7 @@ pub fn verify(
hash(ThreadInfo {
debug,
quiet,
zero,
thread_id: i,
filenames: safe_buf,
#[cfg(feature = "all")]
@ -239,6 +246,7 @@ pub fn generate(
#[cfg(feature = "all")] algorithm: String,
debug: bool,
quiet: bool,
zero: bool,
#[cfg(feature = "single")] hash_function: fn(Option<File>, Option<String>) -> String,
) -> (
Vec<JoinHandle<Result<(), std::string::String>>>,
@ -266,6 +274,7 @@ pub fn generate(
hash(ThreadInfo {
debug,
quiet,
zero,
thread_id: i,
filenames: safe_buf,
#[cfg(feature = "all")]

View file

@ -57,6 +57,7 @@ macro_rules! main {
$algorithm,
$args.debug,
$args.quiet,
$args.zero,
$args.check,
$args.files,
#[cfg(feature = "single")]
@ -87,6 +88,7 @@ macro_rules! main {
$algorithm,
$args.debug,
$args.quiet,
$args.zero,
#[cfg(feature = "single")]
$hasher,
);

View file

@ -102,7 +102,7 @@ pub struct Args {
#[arg(
short = 'c',
long,
help = "Read checksums from the file(s) and verify them"
help = "Read checksums from the file(s) and verify them; FILES becomes a filter (see man page)"
)]
pub check: Vec<PathBuf>,