Improve error messages for not finding LBA sources

This commit is contained in:
Jaby
2023-04-13 21:22:49 +02:00
parent 1dd145abea
commit 5d0239bfe8
3 changed files with 16 additions and 9 deletions

View File

@@ -161,7 +161,7 @@ fn parse_configuration(config: config_reader::Configuration) -> Result<(CDDesc,
match file.kind {
config_reader::FileKind::Regular => (types::File::new_regular(file.common.name.as_str(), read_file(&file.path)?)?, false),
config_reader::FileKind::Main(lba_source) => (types::overlay::load_for_main(file.common.name.as_str(), read_file(&file.path)?, lba_source)?, true),
config_reader::FileKind::Overlay(lba_source) => (types::overlay::load_from(file.common.name.as_str(), &file.path, lba_source)?, true),
config_reader::FileKind::Overlay(lba_source) => (types::overlay::load_from(file.common.name.as_str(), &file.path, lba_source)?, true),
}
};

View File

@@ -2,7 +2,7 @@ use super::{bits::{Bit, BitRange}, layout::Layout, File, FileSystemMap};
use super::super::encoder::LengthCalculatorFunction;
use std::path::PathBuf;
use no_comment::{IntoWithoutComments as _, languages};
use tool_helper::{Error, format_if_error, read_file, format_if_error_drop_cause};
use tool_helper::{Error, format_if_error, read_file, read_file_to_string, format_if_error_drop_cause};
pub type LBANameVec = Vec<String>;
@@ -121,7 +121,7 @@ fn load_lba_names(lba_source: PathBuf) -> Result<LBANameVec, Error> {
Ok(file[start..end].to_owned())
}
let file = std::fs::read_to_string(&lba_source)?.chars().without_comments(languages::c()).collect::<String>();
let file = read_file_to_string(&lba_source)?.chars().without_comments(languages::c()).collect::<String>();
let file = get_part_of_interest(file, &lba_source)?;
let mut lba_names = Vec::new();