1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216
/* Copyright [2021] [Cerda] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ //! Tool for making/verifying hashes. //! //! # Library doc //! //! The library it's self is used in this project as well due it contains all needed functions. //! //! ## Data flow //! //! Hash verification //! //! ```plaintext //! Options //! |> create_hashes() //! |> load_hashes() //! |> compare_hashes() //! |> write_hash_comparison_results() //! ``` //! //! Hash creation //! //! ```plaintext //! Options //! |> create_hashes() //! |> write_hashes() //! ``` //! //! # Executable manpage //! //! Exit values and possible errors: //! //! ```text //! 1 - option parsing error //! 2 - hash lengths differ between selected and saved //! 3 - failed to parse hashes file //! N+3 - N files didn't match //! ``` //! //! ## SYNOPSIS //! //! [`QuickDash`](https://github.com/AndreVuillemot160/QuickDash) [OPTIONS] [DIRECTORY] //! //! ## DESCRIPTION //! //! This is a utility for making/checking hashes with blazing-fast speed. All most well-known hash functions are supported, like MD5, SHA1, SHA2 etc. //! It's licensed under Apache-2.0 License. //! //! ## OPTIONS //! //! -a --algorithm <algorithm> //! //! ```text //! Quite simple, select the hash you want. Case-insensitive. //! //! Supported algorithms: SHA{1,2-,3-{224,256,384,512}, CRC32, MD5, BLAKE{2B,2S,3}, XXH3, XXHASH64 //! //! ``` //! //! -c --create //! //! ```text //! A very simple command. What it does, it creates hashes. //! If user didn't specified the name it will use, the name of folder with `.hash` extension. //! //! And will also fail if the output file exists already and the command `--force` is not presented. //! //! Only with `--verify`. Overrides `--verify`. //! ``` //! //! -v --verify //! //! ```text //! Verify directory hashes. Used by default. //! //! Only with `--create`. Overrides `--create`. //! ``` //! //! -d --depth <depth> //! //! ```text //! Set max recursion depth to `depth`. Default: 0. //! //! Only with `--recursive`. Overrides `--recursive`. //! ``` //! //! -r --recursive //! //! ```text //! Set max recursion depth to infinity. By default it doesn't recurse. //! //! Only with `--depth`. Overrides `--depth`. //! ``` //! //! --follow-symlinks //! //! ```text //! Recurse down symlinks. Default. //! ``` //! //! --no-follow-symlinks //! //! ```text //! Don't recurse down symlinks. //! ``` //! //! -i --ignore <filename[,filename2][,filename3][,filenameN]...>... //! //! ```text //! Add filename(s) to ignored files list. Default: not used. //! //! The program marks the files that will be ignored. The specified ignored files will not come to the output file. //! //! Can be used multiple times. //! ``` //! //! --force //! //! ```text //! Rewrite the output file in `--create` mode. //! ``` //! //! -j --jobs [jobs] //! //! ```text //! Amount of threads used for hashing. Default: # of CPU threads //! //! One thread can hash one file at a time, potentially speeding up hashing //! up to `jobs` times. //! //! No/empty value: # of CPU threads. value = 0: maximum, of u8 (255) //! //! ``` //! //! [DIRECTORY] //! //! ```text //! Directory to create/verify hash for. By default is current workdir. //! ``` //! //! ## EXAMPLES //! //! `quickdash` [`-v`] [`-f` *infile*] //! //! ```text //! Verify the current directory using the saved hashes. //! //! `-v` is not necessary as it's the default. //! //! *infile* defaults to "`DIRECTORY`.hash" //! //! Example output: //! File added: "file_that_hasnt_been_before" //! File removed: "file_that_was_originally_here_before_but_not_now" //! File ignored: "file_specified_with_ignore_now_or_during_creation" //! //! File "file_that_did_not_change" matches //! File "changed_file" doesn't match //! Was: foo //! Is : bar //! ``` //! //! `examples` `-c` [`-f` *outfile*] [`--force`] //! //! ```text //! Create hashes of the current directory tree for later verification. //! //! *outfile* defaults to "`DIRECTORY`.hash". //! //! Use `--force` to override *outfile*. //! //! *outfile* contents: //! F013BF0B163785CBB3BE52DE981E069E2B64E1CAC863815AC7BEED63E1734BAE Cargo.toml //! E84E380AEBDA3D98E96267201D61784C3D6FFB128C4D669E6C1D994C7D7BF32B Cross.toml //! ``` #![deny( anonymous_parameters, clippy::all, const_err, illegal_floating_point_literal_pattern, late_bound_lifetime_arguments, path_statements, patterns_in_fns_without_body, rust_2018_idioms, trivial_casts, trivial_numeric_casts, unsafe_code, unused_extern_crates )] mod algorithms; mod error; mod hashing; mod options; pub mod operations; pub mod utilities; pub use crate::algorithms::Algorithm; pub use crate::error::Error; pub use crate::hashing::*; pub use crate::options::Options;