tar: better error reporting

This commit is contained in:
2025-10-17 09:38:28 +03:00
parent ecf1c18240
commit bb4e805733
3 changed files with 12 additions and 13 deletions
+1 -4
View File
@@ -1,7 +1,4 @@
use std::{
fmt,
io::{self, Stdout, Write},
};
use std::io::{self, Stdout, Write};
use cross::term::{TermKey, TerminalInput};
+9 -7
View File
@@ -1,7 +1,6 @@
use std::{
fmt,
fs::{self, File},
io::{self, stdout, BufWriter, Read, Seek, Write},
io::{self, BufWriter, Read, Seek, Write},
path::{Path, PathBuf},
process::ExitCode,
};
@@ -42,6 +41,8 @@ enum Error {
NoAction,
#[error("Multiple actions specified, use only -c/-t/-x")]
MultipleActions,
#[error("No inputs specified, aborting")]
NoInputs,
}
trait ContextualizeError {
@@ -87,7 +88,7 @@ fn create_archive(
.contextualize(fs_path)?;
Ok(())
} else if fs_path.is_dir() {
let mut dir = fs::read_dir(fs_path).contextualize(fs_path)?;
let dir = fs::read_dir(fs_path).contextualize(fs_path)?;
for entry in dir {
let entry = entry.contextualize(fs_path)?;
let filename = entry.file_name();
@@ -102,12 +103,13 @@ fn create_archive(
}
Ok(())
} else {
todo!()
eprintln!("Skipping {}: not supported", fs_path.display());
Ok(())
}
}
if inputs.is_empty() {
todo!();
return Err(Error::NoInputs);
}
let archive = output.as_ref();
@@ -126,8 +128,8 @@ fn create_archive(
// fs path == archive path
write_path(&mut writer, input, input)?;
} else {
todo!();
// write_path(&mut writer, chdir, chdir.join(input).as_path())?;
let fs_path = chdir.join(input);
write_path(&mut writer, &fs_path, input)?;
}
}
+2 -2
View File
@@ -24,7 +24,7 @@ use cross::{
};
use error::Error;
use exec::Outcome;
use stuff::readline::{self, ReadlineError, ReadlineProvider};
use stuff::readline::{self, ReadlineProvider};
pub mod builtin;
pub mod command;
@@ -112,7 +112,7 @@ impl ShellInput {
&mut self,
readline_provider: &mut ReadlineProviderImpl,
line: &mut String,
continuation: bool,
_continuation: bool,
) -> Result<usize, Error> {
match self {
Self::File(file) => Ok(file.read_line(line)?),