Huge refactor. Introduce anyhow for error handling.

This commit is contained in:
Cutieguwu
2025-12-29 15:31:01 -05:00
parent e98383d9e5
commit 4b5460f754
13 changed files with 411 additions and 746 deletions

View File

@@ -1,4 +1,5 @@
use std::io::{self, Seek, SeekFrom};
use std::path::{Path, PathBuf};
/// Get length of data stream.
/// Physical length of data stream in bytes
@@ -13,3 +14,23 @@ pub fn get_stream_length<S: Seek>(stream: &mut S) -> io::Result<u64> {
len
}
/// Generates a file path if one not provided.
/// source_name for fallback name.
pub fn get_path<P>(file_path: &Option<P>, source_name: &P, extension: &str) -> Option<PathBuf>
where
P: AsRef<Path>,
{
if let Some(f) = file_path {
return f.as_ref().to_path_buf().into();
}
PathBuf::from(format!(
"{:?}.{}",
source_name.as_ref().to_str()?,
extension
))
.as_path()
.to_owned()
.into()
}