mirror of
https://github.com/edera-dev/sprout.git
synced 2025-12-20 00:40:18 +00:00
add efi shell so that chainloading multiple items can be tested
This commit is contained in:
24
src/utils.rs
24
src/utils.rs
@@ -1,7 +1,7 @@
|
||||
use uefi::CString16;
|
||||
use uefi::fs::{FileSystem, Path};
|
||||
use uefi::proto::device_path::PoolDevicePath;
|
||||
use uefi::proto::device_path::text::DevicePathFromText;
|
||||
use uefi::proto::device_path::text::{AllowShortcuts, DevicePathFromText, DisplayOnly};
|
||||
use uefi::proto::device_path::{DevicePath, PoolDevicePath};
|
||||
use uefi::proto::media::fs::SimpleFileSystem;
|
||||
|
||||
pub fn text_to_device_path(path: &str) -> PoolDevicePath {
|
||||
@@ -17,6 +17,26 @@ pub fn text_to_device_path(path: &str) -> PoolDevicePath {
|
||||
.expect("unable to convert text to device path")
|
||||
}
|
||||
|
||||
pub fn device_path_root(path: &DevicePath) -> String {
|
||||
let mut path = path
|
||||
.node_iter()
|
||||
.filter_map(|item| {
|
||||
let item = item
|
||||
.to_string(DisplayOnly(false), AllowShortcuts(false))
|
||||
.expect("unable to convert device path to string");
|
||||
if item.to_string().contains("(") {
|
||||
Some(item)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.map(|item| item.to_string())
|
||||
.collect::<Vec<_>>()
|
||||
.join("/");
|
||||
path.push('/');
|
||||
path
|
||||
}
|
||||
|
||||
pub fn read_file_contents(path: &str) -> Vec<u8> {
|
||||
let fs = uefi::boot::open_protocol_exclusive::<SimpleFileSystem>(
|
||||
uefi::boot::get_handle_for_protocol::<SimpleFileSystem>().expect("no filesystem protocol"),
|
||||
|
||||
Reference in New Issue
Block a user