use std::path::{Path, PathBuf};
use std::fs;
use std::io;
pub fn generate_aux_file_path(source_path: &Path) -> PathBuf {
let mut aux_path = source_path.to_path_buf();
let file_stem = aux_path.file_stem()
.and_then(|s| s.to_str())
.unwrap_or("unknown");
aux_path.set_file_name(format!("{file_stem}_seams2.txt"));
aux_path
}
pub fn create_complete_aux_file<P: AsRef<Path>>(source_path: P, content: &str) -> Result<PathBuf, io::Error> {
let aux_path = generate_aux_file_path(source_path.as_ref());
let content_with_newline = if content.ends_with('\n') {
content.to_string()
} else {
format!("{content}\n")
};
fs::write(&aux_path, content_with_newline)?;
Ok(aux_path)
}