use alloc::string::String;
use super::super::boot::options::BootOptions;
use super::super::read::PathSeparator;
use super::super::rrip::RripOptions;
use crate::joliet::JolietLevel;
#[derive(Debug, Clone, Default)]
pub struct HybridBootOptions {
pub partition_scheme: PartitionScheme,
pub mbr_bootstrap: Option<alloc::vec::Vec<u8>>,
pub bootable: bool,
}
impl HybridBootOptions {
pub fn mbr() -> Self {
Self {
partition_scheme: PartitionScheme::Mbr,
mbr_bootstrap: None,
bootable: true,
}
}
pub fn gpt() -> Self {
Self {
partition_scheme: PartitionScheme::Gpt,
mbr_bootstrap: None,
bootable: false,
}
}
pub fn hybrid() -> Self {
Self {
partition_scheme: PartitionScheme::Hybrid,
mbr_bootstrap: None,
bootable: true,
}
}
pub fn with_bootstrap(mut self, bootstrap: alloc::vec::Vec<u8>) -> Self {
self.mbr_bootstrap = Some(bootstrap);
self
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum PartitionScheme {
#[default]
None,
Mbr,
Gpt,
Hybrid,
}
#[derive(Debug, Clone)]
pub struct FormatOptions {
pub volume_name: String,
pub system_id: Option<String>,
pub volume_set_id: Option<String>,
pub publisher_id: Option<String>,
pub preparer_id: Option<String>,
pub application_id: Option<String>,
pub sector_size: usize,
pub features: CreationFeatures,
pub path_separator: PathSeparator,
pub strict_charset: bool,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum BaseIsoLevel {
Level1 {
supports_lowercase: bool,
supports_rrip: bool,
},
Level2 {
supports_lowercase: bool,
supports_rrip: bool,
},
}
#[derive(Debug, Clone)]
pub struct CreationFeatures {
pub filenames: BaseIsoLevel,
pub long_filenames: bool,
pub joliet: Option<JolietLevel>,
pub rock_ridge: Option<RripOptions>,
pub el_torito: Option<BootOptions>,
pub hybrid_boot: Option<HybridBootOptions>,
}
impl Default for CreationFeatures {
fn default() -> Self {
Self {
filenames: BaseIsoLevel::Level1 {
supports_lowercase: false,
supports_rrip: false,
},
long_filenames: false,
joliet: None,
rock_ridge: None,
el_torito: None,
hybrid_boot: None,
}
}
}
impl CreationFeatures {
pub fn with_rock_ridge() -> Self {
Self {
filenames: BaseIsoLevel::Level1 {
supports_lowercase: false,
supports_rrip: true,
},
rock_ridge: Some(RripOptions::default()),
..Default::default()
}
}
pub fn with_joliet(level: JolietLevel) -> Self {
Self {
joliet: Some(level),
..Default::default()
}
}
pub fn with_extensions() -> Self {
Self {
filenames: BaseIsoLevel::Level1 {
supports_lowercase: false,
supports_rrip: true,
},
joliet: Some(JolietLevel::Level3),
rock_ridge: Some(RripOptions::default()),
..Default::default()
}
}
pub fn with_hybrid_boot(scheme: PartitionScheme) -> Self {
Self {
hybrid_boot: Some(HybridBootOptions {
partition_scheme: scheme,
mbr_bootstrap: None,
bootable: true,
}),
..Default::default()
}
}
}
impl From<BaseIsoLevel> for crate::file::EntryType {
fn from(value: BaseIsoLevel) -> Self {
match value {
BaseIsoLevel::Level1 {
supports_lowercase,
supports_rrip,
} => Self::Level1 {
supports_lowercase,
supports_rrip,
},
BaseIsoLevel::Level2 {
supports_lowercase,
supports_rrip,
} => Self::Level2 {
supports_lowercase,
supports_rrip,
},
}
}
}