You've already forked uutils.github.io
mirror of
https://github.com/uutils/uutils.github.io.git
synced 2026-06-10 16:12:28 -07:00
deploy: f0e8d44e6e
This commit is contained in:
@@ -272,6 +272,23 @@
|
||||
<a href="#272" id="272">272</a>
|
||||
<a href="#273" id="273">273</a>
|
||||
<a href="#274" id="274">274</a>
|
||||
<a href="#275" id="275">275</a>
|
||||
<a href="#276" id="276">276</a>
|
||||
<a href="#277" id="277">277</a>
|
||||
<a href="#278" id="278">278</a>
|
||||
<a href="#279" id="279">279</a>
|
||||
<a href="#280" id="280">280</a>
|
||||
<a href="#281" id="281">281</a>
|
||||
<a href="#282" id="282">282</a>
|
||||
<a href="#283" id="283">283</a>
|
||||
<a href="#284" id="284">284</a>
|
||||
<a href="#285" id="285">285</a>
|
||||
<a href="#286" id="286">286</a>
|
||||
<a href="#287" id="287">287</a>
|
||||
<a href="#288" id="288">288</a>
|
||||
<a href="#289" id="289">289</a>
|
||||
<a href="#290" id="290">290</a>
|
||||
<a href="#291" id="291">291</a>
|
||||
</pre><pre class="rust"><code><span class="comment">// This file is part of the uutils coreutils package.
|
||||
//
|
||||
// (c) Michael Gehring <mg@ebfe.org>
|
||||
@@ -280,7 +297,7 @@
|
||||
// file that was distributed with this source code.
|
||||
|
||||
// spell-checker:ignore (ToDO) fname, algo
|
||||
</span><span class="kw">use </span>clap::{crate_version, Arg, Command};
|
||||
</span><span class="kw">use </span>clap::{crate_version, Arg, ArgAction, Command};
|
||||
<span class="kw">use </span>hex::encode;
|
||||
<span class="kw">use </span>std::ffi::OsStr;
|
||||
<span class="kw">use </span>std::fs::File;
|
||||
@@ -377,6 +394,7 @@
|
||||
algo_name: <span class="kw-2">&</span><span class="lifetime">'static </span>str,
|
||||
digest: Box<<span class="kw">dyn </span>Digest + <span class="lifetime">'static</span>>,
|
||||
output_bits: usize,
|
||||
untagged: bool,
|
||||
}
|
||||
|
||||
<span class="doccomment">/// Calculate checksum
|
||||
@@ -435,12 +453,20 @@
|
||||
),
|
||||
(ALGORITHM_OPTIONS_CRC, <span class="bool-val">true</span>) => <span class="macro">println!</span>(<span class="string">"{sum} {sz}"</span>),
|
||||
(ALGORITHM_OPTIONS_CRC, <span class="bool-val">false</span>) => <span class="macro">println!</span>(<span class="string">"{sum} {sz} {}"</span>, filename.display()),
|
||||
(ALGORITHM_OPTIONS_BLAKE2B, <span class="kw">_</span>) => <span class="macro">println!</span>(<span class="string">"BLAKE2b ({}) = {sum}"</span>, filename.display()),
|
||||
<span class="kw">_ </span>=> <span class="macro">println!</span>(
|
||||
<span class="string">"{} ({}) = {sum}"</span>,
|
||||
options.algo_name.to_ascii_uppercase(),
|
||||
filename.display()
|
||||
),
|
||||
(ALGORITHM_OPTIONS_BLAKE2B, <span class="kw">_</span>) <span class="kw">if </span>!options.untagged => {
|
||||
<span class="macro">println!</span>(<span class="string">"BLAKE2b ({}) = {sum}"</span>, filename.display());
|
||||
}
|
||||
<span class="kw">_ </span>=> {
|
||||
<span class="kw">if </span>options.untagged {
|
||||
<span class="macro">println!</span>(<span class="string">"{sum} {}"</span>, filename.display());
|
||||
} <span class="kw">else </span>{
|
||||
<span class="macro">println!</span>(
|
||||
<span class="string">"{} ({}) = {sum}"</span>,
|
||||
options.algo_name.to_ascii_uppercase(),
|
||||
filename.display()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -482,8 +508,9 @@
|
||||
}
|
||||
|
||||
<span class="kw">mod </span>options {
|
||||
<span class="kw">pub static </span>FILE: <span class="kw-2">&</span>str = <span class="string">"file"</span>;
|
||||
<span class="kw">pub static </span>ALGORITHM: <span class="kw-2">&</span>str = <span class="string">"algorithm"</span>;
|
||||
<span class="kw">pub const </span>ALGORITHM: <span class="kw-2">&</span>str = <span class="string">"algorithm"</span>;
|
||||
<span class="kw">pub const </span>FILE: <span class="kw-2">&</span>str = <span class="string">"file"</span>;
|
||||
<span class="kw">pub const </span>UNTAGGED: <span class="kw-2">&</span>str = <span class="string">"untagged"</span>;
|
||||
}
|
||||
|
||||
<span class="attr">#[uucore::main]
|
||||
@@ -502,6 +529,7 @@
|
||||
algo_name: name,
|
||||
digest: algo,
|
||||
output_bits: bits,
|
||||
untagged: matches.get_flag(options::UNTAGGED),
|
||||
};
|
||||
|
||||
<span class="kw">match </span>matches.get_many::<String>(options::FILE) {
|
||||
@@ -544,6 +572,12 @@
|
||||
ALGORITHM_OPTIONS_SM3,
|
||||
]),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(options::UNTAGGED)
|
||||
.long(options::UNTAGGED)
|
||||
.help(<span class="string">"create a reversed style checksum, without digest type"</span>)
|
||||
.action(ArgAction::SetTrue),
|
||||
)
|
||||
.after_help(AFTER_HELP)
|
||||
}
|
||||
</code></pre></div>
|
||||
|
||||
@@ -454,6 +454,16 @@
|
||||
<a href="#454" id="454">454</a>
|
||||
<a href="#455" id="455">455</a>
|
||||
<a href="#456" id="456">456</a>
|
||||
<a href="#457" id="457">457</a>
|
||||
<a href="#458" id="458">458</a>
|
||||
<a href="#459" id="459">459</a>
|
||||
<a href="#460" id="460">460</a>
|
||||
<a href="#461" id="461">461</a>
|
||||
<a href="#462" id="462">462</a>
|
||||
<a href="#463" id="463">463</a>
|
||||
<a href="#464" id="464">464</a>
|
||||
<a href="#465" id="465">465</a>
|
||||
<a href="#466" id="466">466</a>
|
||||
</pre><pre class="rust"><code><span class="comment">// * This file is part of the uutils coreutils package.
|
||||
// *
|
||||
// * For the full copyright and license information, please view the LICENSE
|
||||
@@ -860,8 +870,18 @@
|
||||
</span><span class="prelude-val">Err</span>(e) => <span class="macro">show_error!</span>(<span class="string">"{}"</span>, e),
|
||||
}
|
||||
}
|
||||
|
||||
<span class="comment">// Copy the attributes from the root directory to the target directory.
|
||||
</span>copy_attributes(root, target, <span class="kw-2">&</span>options.attributes)<span class="question-mark">?</span>;
|
||||
</span><span class="kw">if </span>options.parents {
|
||||
<span class="kw">let </span>dest = target.join(root.file_name().unwrap());
|
||||
copy_attributes(root, dest.as_path(), <span class="kw-2">&</span>options.attributes)<span class="question-mark">?</span>;
|
||||
<span class="kw">for </span>(x, y) <span class="kw">in </span>aligned_ancestors(root, dest.as_path()) {
|
||||
copy_attributes(x, y, <span class="kw-2">&</span>options.attributes)<span class="question-mark">?</span>;
|
||||
}
|
||||
} <span class="kw">else </span>{
|
||||
copy_attributes(root, target, <span class="kw-2">&</span>options.attributes)<span class="question-mark">?</span>;
|
||||
}
|
||||
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}
|
||||
|
||||
|
||||
@@ -1896,26 +1896,6 @@
|
||||
<a href="#1896" id="1896">1896</a>
|
||||
<a href="#1897" id="1897">1897</a>
|
||||
<a href="#1898" id="1898">1898</a>
|
||||
<a href="#1899" id="1899">1899</a>
|
||||
<a href="#1900" id="1900">1900</a>
|
||||
<a href="#1901" id="1901">1901</a>
|
||||
<a href="#1902" id="1902">1902</a>
|
||||
<a href="#1903" id="1903">1903</a>
|
||||
<a href="#1904" id="1904">1904</a>
|
||||
<a href="#1905" id="1905">1905</a>
|
||||
<a href="#1906" id="1906">1906</a>
|
||||
<a href="#1907" id="1907">1907</a>
|
||||
<a href="#1908" id="1908">1908</a>
|
||||
<a href="#1909" id="1909">1909</a>
|
||||
<a href="#1910" id="1910">1910</a>
|
||||
<a href="#1911" id="1911">1911</a>
|
||||
<a href="#1912" id="1912">1912</a>
|
||||
<a href="#1913" id="1913">1913</a>
|
||||
<a href="#1914" id="1914">1914</a>
|
||||
<a href="#1915" id="1915">1915</a>
|
||||
<a href="#1916" id="1916">1916</a>
|
||||
<a href="#1917" id="1917">1917</a>
|
||||
<a href="#1918" id="1918">1918</a>
|
||||
</pre><pre class="rust"><code><span class="attr">#![allow(clippy::missing_safety_doc)]
|
||||
#![allow(clippy::extra_unused_lifetimes)]
|
||||
|
||||
@@ -3069,14 +3049,20 @@
|
||||
} <span class="kw">else </span>{
|
||||
<span class="comment">// Copy as file
|
||||
</span><span class="kw">let </span>dest = construct_dest_path(source_path, target, target_type, options)<span class="question-mark">?</span>;
|
||||
copy_file(
|
||||
<span class="kw">let </span>res = copy_file(
|
||||
progress_bar,
|
||||
source_path,
|
||||
dest.as_path(),
|
||||
options,
|
||||
symlinked_files,
|
||||
<span class="bool-val">true</span>,
|
||||
)
|
||||
);
|
||||
<span class="kw">if </span>options.parents {
|
||||
<span class="kw">for </span>(x, y) <span class="kw">in </span>aligned_ancestors(source, dest.as_path()) {
|
||||
copy_attributes(x, y, <span class="kw-2">&</span>options.attributes)<span class="question-mark">?</span>;
|
||||
}
|
||||
}
|
||||
res
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3622,11 +3608,6 @@
|
||||
}
|
||||
|
||||
copy_attributes(source, dest, <span class="kw-2">&</span>options.attributes)<span class="question-mark">?</span>;
|
||||
<span class="kw">if </span>options.parents && should_preserve_attribute(options) {
|
||||
<span class="kw">for </span>(x, y) <span class="kw">in </span>aligned_ancestors(source, dest) {
|
||||
copy_attributes(x, y, <span class="kw-2">&</span>options.attributes)<span class="question-mark">?</span>;
|
||||
}
|
||||
}
|
||||
|
||||
<span class="kw">if let </span><span class="prelude-val">Some</span>(progress_bar) = progress_bar {
|
||||
progress_bar.inc(fs::metadata(source)<span class="question-mark">?</span>.len());
|
||||
@@ -3676,27 +3657,6 @@
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}
|
||||
|
||||
<span class="kw">fn </span>should_preserve_attribute(options: <span class="kw-2">&</span>Options) -> bool {
|
||||
<span class="kw">let </span>checks = [
|
||||
<span class="kw-2">&</span>options.attributes.mode,
|
||||
<span class="kw-2">&</span>options.attributes.timestamps,
|
||||
<span class="kw-2">&</span>options.attributes.links,
|
||||
<span class="kw-2">&</span>options.attributes.context,
|
||||
<span class="kw-2">&</span>options.attributes.xattr,
|
||||
];
|
||||
|
||||
<span class="attr">#[cfg(unix)]
|
||||
</span><span class="kw">let </span>checks = [
|
||||
checks.as_slice(),
|
||||
[<span class="kw-2">&</span>options.attributes.ownership].as_slice(),
|
||||
]
|
||||
.concat();
|
||||
|
||||
checks
|
||||
.iter()
|
||||
.any(|attr| <span class="macro">matches!</span>(attr, Preserve::Yes { .. }))
|
||||
}
|
||||
|
||||
<span class="comment">// "Copies" a FIFO by creating a new one. This workaround is because Rust's
|
||||
// built-in fs::copy does not handle FIFOs (see rust-lang/rust/issues/79390).
|
||||
</span><span class="attr">#[cfg(unix)]
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user