Include size in WimImage

This commit is contained in:
2Shirt 2025-11-30 20:46:55 -08:00
parent e873ec9602
commit c572716ef9
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C

View file

@ -1,3 +1,4 @@
use core::system::disk::bytes_to_string;
// This file is part of Deja-Vu.
//
// Deja-Vu is free software: you can redistribute it and/or modify it
@ -112,6 +113,7 @@ pub struct WimImage {
pub build: String,
pub index: String,
pub name: String,
pub size: u64,
pub spbuild: String,
pub version: String,
}
@ -138,7 +140,15 @@ impl fmt::Display for WimImage {
} else {
format!("{}, ", self.version)
};
write!(f, "{} ({}{}.{})", self.name, s, self.build, self.spbuild)
write!(
f,
"{} ({}{}.{}) [{}]",
self.name,
s,
self.build,
self.spbuild,
bytes_to_string(self.size)
)
}
}
@ -249,12 +259,23 @@ pub fn parse_wim_file(wim_file: &str, is_setup: bool) -> std::io::Result<WimFile
if current_element == "SPBUILD" {
image.spbuild = char_data.trim().to_string();
}
if current_element == "TOTALBYTES" {
let result = char_data.trim().parse::<u64>();
if let Ok(size) = result {
image.size = size;
}
}
}
Ok(XmlEvent::EndElement { name }) => {
if name.local_name.to_uppercase() == "IMAGE" {
if image.size == 0 {
break;
}
// Append image to list
if !image.build.is_empty() && !image.name.is_empty() && !image.index.is_empty()
{
if image.build.is_empty() {
image.build.push_str("-14");
}
if !image.name.is_empty() && !image.index.is_empty() {
wim_images.push(image.clone());
}