isobemak 0.2.0

Create bootable ISO images with FAT32 and UEFI (El Torito) support in Rust.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// isobemak/src/utils.rs
use std::{
    fs::File,
    io::{self, Read, Seek},
};

pub const ISO_SECTOR_SIZE: usize = 2048;
pub const FAT32_SECTOR_SIZE: u64 = 512;

/// Pads a file with zeros to align to the ISO sector size.
pub fn pad_sector(f: &mut File) -> io::Result<()> {
    let pos = f.stream_position()?;
    let pad = ISO_SECTOR_SIZE as u64 - (pos % ISO_SECTOR_SIZE as u64);
    if pad != ISO_SECTOR_SIZE as u64 {
        io::copy(&mut io::repeat(0).take(pad), f)?;
    }
    Ok(())
}