refactor: remove magic function and related code

This commit is contained in:
Andrew Phillips (aider)
2025-05-22 13:57:00 -03:00
parent f2d210c4d1
commit a68d75351f
2 changed files with 0 additions and 54 deletions

View File

@@ -54,41 +54,6 @@ pub trait CompressionEngine {
self.copy(file_path, &mut stdout)
}
fn magic(&self, file_path: PathBuf) -> Result<String> {
let mut buffer = [0; libc::BUFSIZ as usize];
let mut reader = self.open(file_path)?;
let buffer_size = reader.read(&mut buffer[..])?;
//let cookie = magic::Cookie::open(magic::cookie::Flags::ERROR)?;
// load the system's default database
//let database = Default::default();
//let cookie = cookie.load(&database).map_err(|error| { anyhow!(error.to_string())})?;
//let magic = cookie.buffer(&buffer[0..n])?;
let program = "file";
let args = ["-bE", "-"];
let process = Command::new(program)
.args(args)
.stdin(Stdio::piped())
.stdout(Stdio::piped())
.spawn()
.context(anyhow!(
"Unable to spawn child process: {:?} {:?}",
program,
args
))?;
let mut stdin = process.stdin.unwrap();
stdin.write_all(&buffer[0..buffer_size])?;
drop(stdin);
let mut magic = String::new();
process.stdout.unwrap().read_to_string(&mut magic)?;
Ok(magic)
}
fn size(&self, file_path: PathBuf) -> Result<usize> {
let mut reader = self.open(file_path)?;
let mut buffer = [0; libc::BUFSIZ as usize];