mod scan;
mod write;
use crate::Result;
use crate::block::BlockDevice;
use crate::fs::archive::ArchiveFs;
pub const MAGIC: &[u8; 8] = b"!<arch>\n";
#[derive(Debug, Clone, Default)]
pub struct ArFormatOpts;
impl ArFormatOpts {
pub fn apply_options(&mut self, _bag: &mut crate::format_opts::OptionMap) -> Result<()> {
Ok(())
}
}
pub struct ArFs(pub ArchiveFs);
impl ArFs {
pub fn open(dev: &mut dyn BlockDevice) -> Result<Self> {
Ok(Self(ArchiveFs::from_index(scan::scan(dev)?)))
}
pub fn format(dev: &mut dyn BlockDevice, _opts: &ArFormatOpts) -> Result<Self> {
Ok(Self(ArchiveFs::writer(
"ar",
Box::new(write::ArWriter::new(dev)),
)))
}
}
impl crate::fs::FilesystemFactory for ArFs {
type FormatOpts = ArFormatOpts;
fn format(dev: &mut dyn BlockDevice, opts: &Self::FormatOpts) -> Result<Self> {
Self::format(dev, opts)
}
fn open(dev: &mut dyn BlockDevice) -> Result<Self> {
Self::open(dev)
}
}
crate::impl_archive_fs_filesystem!(ArFs);