CLeanup, and get domain overlap and mapping adjustment working.

This commit is contained in:
Cutieguwu
2025-12-31 11:07:24 -05:00
parent 4b5460f754
commit c28fee9f82
9 changed files with 662 additions and 140 deletions

View File

@@ -1,6 +1,8 @@
use std::io::{self, Seek, SeekFrom};
use std::path::{Path, PathBuf};
use anyhow::Context;
/// Get length of data stream.
/// Physical length of data stream in bytes
/// (multiple of sector_size, rather than actual).
@@ -17,20 +19,26 @@ pub fn get_stream_length<S: Seek>(stream: &mut S) -> io::Result<u64> {
/// 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>
pub fn get_path<P>(
file_path: &Option<P>,
source_name: &P,
extension: &str,
) -> anyhow::Result<PathBuf>
where
P: AsRef<Path>,
{
if let Some(f) = file_path {
return f.as_ref().to_path_buf().into();
return Ok(f.as_ref().to_path_buf());
}
PathBuf::from(format!(
Ok(PathBuf::from(format!(
"{:?}.{}",
source_name.as_ref().to_str()?,
source_name
.as_ref()
.to_str()
.context("source_name path was not UTF-8 valid.")?,
extension
))
.as_path()
.to_owned()
.into()
.to_owned())
}