This commit is contained in:
sylvestre
2023-05-25 02:38:43 +00:00
parent 83cf621b72
commit ea4f09d3c5
31 changed files with 128 additions and 30 deletions
+21 -1
View File
@@ -563,6 +563,16 @@
<a href="#563" id="563">563</a>
<a href="#564" id="564">564</a>
<a href="#565" id="565">565</a>
<a href="#566" id="566">566</a>
<a href="#567" id="567">567</a>
<a href="#568" id="568">568</a>
<a href="#569" id="569">569</a>
<a href="#570" id="570">570</a>
<a href="#571" id="571">571</a>
<a href="#572" id="572">572</a>
<a href="#573" id="573">573</a>
<a href="#574" id="574">574</a>
<a href="#575" id="575">575</a>
</pre><pre class="rust"><code><span class="comment">// * This file is part of the uutils coreutils package.
// *
// * (c) Martin Kysel &lt;code@martinkysel.com&gt;
@@ -669,7 +679,17 @@
<span class="kw">if </span>length &gt; <span class="number">1 </span>{
buff.push_str(<span class="kw-2">&amp;</span>MULTI_FILE_TOP_PROMPT.replace(<span class="string">&quot;{}&quot;</span>, file.to_str().unwrap()));
}
<span class="kw">let </span><span class="kw-2">mut </span>reader = BufReader::new(File::open(file).unwrap());
<span class="kw">let </span>opened_file = <span class="kw">match </span>File::open(file) {
<span class="prelude-val">Err</span>(why) =&gt; {
terminal::disable_raw_mode().unwrap();
<span class="kw">return </span><span class="prelude-val">Err</span>(USimpleError::new(
<span class="number">1</span>,
<span class="macro">format!</span>(<span class="string">&quot;cannot open {}: {}&quot;</span>, file.quote(), why.kind()),
));
}
<span class="prelude-val">Ok</span>(opened_file) =&gt; opened_file,
};
<span class="kw">let </span><span class="kw-2">mut </span>reader = BufReader::new(opened_file);
reader.read_to_string(<span class="kw-2">&amp;mut </span>buff).unwrap();
more(<span class="kw-2">&amp;</span>buff, <span class="kw-2">&amp;mut </span>stdout, next_file.copied(), <span class="kw-2">&amp;</span>options)<span class="question-mark">?</span>;
buff.clear();
+78
View File
@@ -551,6 +551,45 @@
<a href="#551" id="551">551</a>
<a href="#552" id="552">552</a>
<a href="#553" id="553">553</a>
<a href="#554" id="554">554</a>
<a href="#555" id="555">555</a>
<a href="#556" id="556">556</a>
<a href="#557" id="557">557</a>
<a href="#558" id="558">558</a>
<a href="#559" id="559">559</a>
<a href="#560" id="560">560</a>
<a href="#561" id="561">561</a>
<a href="#562" id="562">562</a>
<a href="#563" id="563">563</a>
<a href="#564" id="564">564</a>
<a href="#565" id="565">565</a>
<a href="#566" id="566">566</a>
<a href="#567" id="567">567</a>
<a href="#568" id="568">568</a>
<a href="#569" id="569">569</a>
<a href="#570" id="570">570</a>
<a href="#571" id="571">571</a>
<a href="#572" id="572">572</a>
<a href="#573" id="573">573</a>
<a href="#574" id="574">574</a>
<a href="#575" id="575">575</a>
<a href="#576" id="576">576</a>
<a href="#577" id="577">577</a>
<a href="#578" id="578">578</a>
<a href="#579" id="579">579</a>
<a href="#580" id="580">580</a>
<a href="#581" id="581">581</a>
<a href="#582" id="582">582</a>
<a href="#583" id="583">583</a>
<a href="#584" id="584">584</a>
<a href="#585" id="585">585</a>
<a href="#586" id="586">586</a>
<a href="#587" id="587">587</a>
<a href="#588" id="588">588</a>
<a href="#589" id="589">589</a>
<a href="#590" id="590">590</a>
<a href="#591" id="591">591</a>
<a href="#592" id="592">592</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
@@ -824,6 +863,11 @@
</span>}
}
} <span class="kw">else </span>{
<span class="self">self</span>.print_verbose_ownership_retained_as(
path,
meta.uid(),
<span class="self">self</span>.dest_gid.map(|<span class="kw">_</span>| meta.gid()),
);
<span class="number">0
</span>};
@@ -885,6 +929,11 @@
};
<span class="kw">if </span>!<span class="self">self</span>.matched(meta.uid(), meta.gid()) {
<span class="self">self</span>.print_verbose_ownership_retained_as(
path,
meta.uid(),
<span class="self">self</span>.dest_gid.map(|<span class="kw">_</span>| meta.gid()),
);
<span class="kw">continue</span>;
}
@@ -946,6 +995,35 @@
IfFrom::UserGroup(u, g) =&gt; u == uid &amp;&amp; g == gid,
}
}
<span class="kw">fn </span>print_verbose_ownership_retained_as(<span class="kw-2">&amp;</span><span class="self">self</span>, path: <span class="kw-2">&amp;</span>Path, uid: u32, gid: <span class="prelude-ty">Option</span>&lt;u32&gt;) {
<span class="kw">if </span><span class="self">self</span>.verbosity.level == VerbosityLevel::Verbose {
<span class="kw">match </span>(<span class="self">self</span>.dest_uid, <span class="self">self</span>.dest_gid, gid) {
(<span class="prelude-val">Some</span>(<span class="kw">_</span>), <span class="prelude-val">Some</span>(<span class="kw">_</span>), <span class="prelude-val">Some</span>(gid)) =&gt; {
<span class="macro">println!</span>(
<span class="string">&quot;ownership of {} retained as {}:{}&quot;</span>,
path.quote(),
entries::uid2usr(uid).unwrap_or_else(|<span class="kw">_</span>| uid.to_string()),
entries::gid2grp(gid).unwrap_or_else(|<span class="kw">_</span>| gid.to_string()),
);
}
(<span class="prelude-val">None</span>, <span class="prelude-val">Some</span>(<span class="kw">_</span>), <span class="prelude-val">Some</span>(gid)) =&gt; {
<span class="macro">println!</span>(
<span class="string">&quot;ownership of {} retained as {}&quot;</span>,
path.quote(),
entries::gid2grp(gid).unwrap_or_else(|<span class="kw">_</span>| gid.to_string()),
);
}
(<span class="kw">_</span>, <span class="kw">_</span>, <span class="kw">_</span>) =&gt; {
<span class="macro">println!</span>(
<span class="string">&quot;ownership of {} retained as {}&quot;</span>,
path.quote(),
entries::uid2usr(uid).unwrap_or_else(|<span class="kw">_</span>| uid.to_string()),
);
}
}
}
}
}
<span class="kw">pub mod </span>options {
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
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
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

Some files were not shown because too many files have changed in this diff Show More