mirror of
https://github.com/edera-dev/sprout.git
synced 2025-12-19 17:30:17 +00:00
begin documenting some functions and align error messages
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
mod entry;
|
||||
|
||||
use crate::config::EntryDeclaration;
|
||||
use crate::context::SproutContext;
|
||||
use crate::entries::EntryDeclaration;
|
||||
use crate::generators::bls::entry::BlsEntry;
|
||||
use crate::utils;
|
||||
use anyhow::{Context, Result};
|
||||
@@ -13,6 +11,8 @@ use uefi::fs::{FileSystem, Path};
|
||||
use uefi::proto::device_path::text::{AllowShortcuts, DisplayOnly};
|
||||
use uefi::proto::media::fs::SimpleFileSystem;
|
||||
|
||||
mod entry;
|
||||
|
||||
#[derive(Serialize, Deserialize, Default, Clone)]
|
||||
pub struct BlsConfiguration {
|
||||
pub entry: EntryDeclaration,
|
||||
@@ -32,19 +32,19 @@ pub fn generate(
|
||||
|
||||
let path = context.stamp(&bls.path);
|
||||
let resolved = utils::resolve_path(context.root().loaded_image_path()?, &path)
|
||||
.context("failed to resolve bls path")?;
|
||||
.context("unable to resolve bls path")?;
|
||||
let fs = uefi::boot::open_protocol_exclusive::<SimpleFileSystem>(resolved.filesystem_handle)
|
||||
.context("failed to open bls filesystem")?;
|
||||
.context("unable to open bls filesystem")?;
|
||||
let mut fs = FileSystem::new(fs);
|
||||
let sub_text_path = resolved
|
||||
.sub_path
|
||||
.to_string(DisplayOnly(false), AllowShortcuts(false))
|
||||
.context("failed to convert subpath to string")?;
|
||||
.context("unable to convert subpath to string")?;
|
||||
let entries_path = Path::new(&sub_text_path);
|
||||
|
||||
let entries_iter = fs
|
||||
.read_dir(entries_path)
|
||||
.context("failed to read bls entries")?;
|
||||
.context("unable to read bls entries")?;
|
||||
|
||||
for entry in entries_iter {
|
||||
let entry = entry?;
|
||||
@@ -57,13 +57,13 @@ pub fn generate(
|
||||
}
|
||||
|
||||
let full_entry_path = CString16::try_from(format!("{}\\{}", sub_text_path, name).as_str())
|
||||
.context("failed to construct full entry path")?;
|
||||
.context("unable to construct full entry path")?;
|
||||
let full_entry_path = Path::new(&full_entry_path);
|
||||
let content = fs
|
||||
.read(full_entry_path)
|
||||
.context("failed to read bls file")?;
|
||||
let content = String::from_utf8(content).context("failed to read bls entry as utf8")?;
|
||||
let entry = BlsEntry::from_str(&content).context("failed to parse bls entry")?;
|
||||
.context("unable to read bls file")?;
|
||||
let content = String::from_utf8(content).context("unable to read bls entry as utf8")?;
|
||||
let entry = BlsEntry::from_str(&content).context("unable to parse bls entry")?;
|
||||
|
||||
if !entry.is_valid() {
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user