Support writing LBA information into main file
This commit is contained in:
@@ -8,5 +8,6 @@ edition = "2021"
|
||||
[dependencies]
|
||||
byteorder = "*"
|
||||
cdtypes = {path = "../cdtypes"}
|
||||
envmnt = "*"
|
||||
lz4 = "*"
|
||||
paste = "*"
|
@@ -1,4 +1,5 @@
|
||||
use std::{boxed::Box, io::{BufReader, BufWriter, Read, Write}, path::PathBuf};
|
||||
use envmnt::{ExpandOptions, ExpansionType};
|
||||
|
||||
pub mod bits;
|
||||
pub mod compress;
|
||||
@@ -22,6 +23,20 @@ macro_rules! format_if_error {
|
||||
};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! format_if_error_drop_cause {
|
||||
($result:expr, $format_text:literal) => {
|
||||
tool_helper::callback_if_any_error($result, |error_text| {
|
||||
format!($format_text)
|
||||
})
|
||||
};
|
||||
($result:expr, $format_text:literal, $($arg:expr)*) => {
|
||||
tool_helper::callback_if_any_error($result, |error_text| {
|
||||
format!($format_text, $($arg),*)
|
||||
})
|
||||
};
|
||||
}
|
||||
|
||||
pub struct Error {
|
||||
pub exit_code: i32,
|
||||
pub text: String,
|
||||
@@ -123,6 +138,10 @@ pub fn callback_if_any_error<F: Fn(String) -> String, T, E: std::string::ToStrin
|
||||
}
|
||||
}
|
||||
|
||||
pub fn path_with_env_from(path: &str) -> PathBuf {
|
||||
PathBuf::from(envmnt::expand(path, Some(ExpandOptions{expansion_type: Some(ExpansionType::All), default_to_empty: false})))
|
||||
}
|
||||
|
||||
pub fn open_output_file(output_path: &PathBuf) -> Result<BufWriter<std::fs::File>, Error> {
|
||||
Ok(std::io::BufWriter::new(std::fs::File::create(output_path)?))
|
||||
}
|
||||
|
Reference in New Issue
Block a user