mirror of
https://github.com/ouch-org/ouch.git
synced 2025-06-07 12:05:46 +00:00
Adding unwrap safety for file_name
This commit is contained in:
parent
baf23fa685
commit
05f82d3aee
@ -114,6 +114,11 @@ pub fn run(command: Command, flags: &oof::Flags) -> crate::Result<()> {
|
|||||||
&& input_extensions.len() < formats.len()
|
&& input_extensions.len() < formats.len()
|
||||||
&& input_extensions.iter().zip(&formats).all(|(inp, out)| inp == out)
|
&& input_extensions.iter().zip(&formats).all(|(inp, out)| inp == out)
|
||||||
{
|
{
|
||||||
|
// Safety:
|
||||||
|
// We checked above that input_extensions isn't empty, so files[0] has a extension.
|
||||||
|
//
|
||||||
|
// Path::extension says: "if there is no file_name, then there is no extension".
|
||||||
|
// Using DeMorgan's law: "if there is extension, then there is file_name".
|
||||||
info!(
|
info!(
|
||||||
"Partial compression detected. Compressing {} into {}",
|
"Partial compression detected. Compressing {} into {}",
|
||||||
to_utf(files[0].as_path().file_name().unwrap()),
|
to_utf(files[0].as_path().file_name().unwrap()),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user