MCPcopy Create free account
hub / github.com/FrameworkComputer/framework-system / dump_winux_image

Function dump_winux_image

framework_lib/src/capsule.rs:195–213  ·  view source on GitHub ↗

Extract the image data from the display capsule to a file

(data: &[u8], header: &DisplayCapsule, filename: &str)

Source from the content-addressed store, hash-verified

193
194/// Extract the image data from the display capsule to a file
195pub fn dump_winux_image(data: &[u8], header: &DisplayCapsule, filename: &str) {
196 let header_len = std::mem::size_of::<DisplayCapsule>();
197 let image_size = header.capsule_header.capsule_image_size as usize - header_len;
198
199 let image = &data[header_len..image_size];
200
201 #[cfg(not(feature = "uefi"))]
202 {
203 let mut file = File::create(filename).unwrap();
204 file.write_all(image).unwrap();
205 }
206 #[cfg(feature = "uefi")]
207 {
208 let ret = crate::fw_uefi::fs::shell_write_file(filename, image);
209 if let Err(err) = ret {
210 println!("Failed to dump winux image: {:?}", err);
211 }
212 }
213}
214
215#[cfg(test)]
216mod tests {

Callers 1

run_with_argsFunction · 0.85

Calls 1

shell_write_fileFunction · 0.85

Tested by

no test coverage detected