LL728/mooniso/impl does not have a README file

    IsoError

    pub(all) suberror IsoError {
    Truncated
    BadBothEndian
    BadSignature
    BadDescriptor(Int)
    NotFound(String)
    NotDirectory(String)
    IsDirectory(String)
    IsSymlink(String)
    HostIoError(String)
    BadDirectoryRecord(Int)
    UnsupportedLayout(String)
    }

    BootEntry

    pub struct BootEntry {
    platform_id : Int
    bootable : Bool
    media_type : Int
    sector_count : Int
    load_lba : Int
    }

    El Torito 启动信息(从启动目录里读出的第一个启动项)。

    BootInfo

    pub struct BootInfo {
    catalog_lba : Int
    platform_id : Int
    bootable : Bool
    media_type : Int
    load_segment : Int
    sector_count : Int
    load_lba : Int
    entries : Array[BootEntry]
    }

    ByteReader

    pub struct ByteReader {
    data : Bytes
    pos : Int
    }

    ByteReader::new

    fn ByteReader::new(data : Bytes) -> ByteReader

    ByteReader::position

    fn ByteReader::position(self : ByteReader) -> Int

    ByteReader::read_ascii

    fn ByteReader::read_ascii(self : ByteReader, n : Int) -> String raise IsoError

    读取定长 ASCII 字段:遇 NUL 截断,尾部空格忽略。

    ByteReader::read_bytes

    fn ByteReader::read_bytes(self : ByteReader, n : Int) -> Bytes raise IsoError

    ByteReader::read_u16_be

    fn ByteReader::read_u16_be(self : ByteReader) -> Int raise IsoError

    ByteReader::read_u16_both

    fn ByteReader::read_u16_both(self : ByteReader) -> Int raise IsoError

    ByteReader::read_u16_le

    fn ByteReader::read_u16_le(self : ByteReader) -> Int raise IsoError

    ByteReader::read_u32_be

    fn ByteReader::read_u32_be(self : ByteReader) -> Int raise IsoError

    ByteReader::read_u32_both

    fn ByteReader::read_u32_both(self : ByteReader) -> Int raise IsoError

    ISO 9660 的 both-endian 4 字节整数:前 4 字节小端,后 4 字节大端。 两份必须一致,否则映像结构不可信。

    ByteReader::read_u32_le

    fn ByteReader::read_u32_le(self : ByteReader) -> Int raise IsoError

    ByteReader::read_u8

    fn ByteReader::read_u8(self : ByteReader) -> UInt raise IsoError

    ByteReader::remaining

    fn ByteReader::remaining(self : ByteReader) -> Int

    ByteReader::seek

    fn ByteReader::seek(self : ByteReader, pos : Int) -> Unit raise IsoError

    ByteReader::skip

    fn ByteReader::skip(self : ByteReader, n : Int) -> Unit raise IsoError

    DirectoryRecord

    pub struct DirectoryRecord {
    extent : Int
    size : Int
    flags : Int
    name : String
    date : RecordDate
    system_use : Bytes
    posix_mode : Int?
    symlink_target : String?
    }

    一条目录记录。

    • extent:文件内容起始的逻辑块号(LBA),目录则是目录数据起始 LBA;
    • size:数据长度(字节),目录则是目录数据总长度;
    • name:去掉 ;版本号 后的名字,目录为原始目录名;
    • is_dir:flags 的 bit 1。

    DirectoryRecord::is_dir

    fn DirectoryRecord::is_dir(self : DirectoryRecord) -> Bool

    DirectoryRecord::is_multi_extent

    fn DirectoryRecord::is_multi_extent(self : DirectoryRecord) -> Bool

    flags 的 bit 7:多段文件,后面还有同名的连续记录。

    DirectoryRecord::is_special

    fn DirectoryRecord::is_special(self : DirectoryRecord) -> Bool

    特殊记录:0x00 是「本目录」,0x01 是「父目录」。
    fn DirectoryRecord::is_symlink(self : DirectoryRecord) -> Bool

    是否为 Rock Ridge 符号链接。

    IsoBuilder

    pub struct IsoBuilder {
    volume_id : String
    joliet : Bool
    rock_ridge : Bool
    boot_path : String?
    efi_path : String?
    boot_load_sectors : Int
    boot_platform : Int
    name_level : Int
    rr_version : Int
    allow_deep_paths : Bool
    boot_info_table : Bool
    dirs : Array[String]
    files : Array[(String, Bytes)]
    symlinks : Array[(String, String)]
    }

    IsoBuilder::add_directory

    fn IsoBuilder::add_directory(self : IsoBuilder, path : String) -> Unit

    IsoBuilder::add_file

    fn IsoBuilder::add_file(self : IsoBuilder, path : String, data : Bytes) -> Unit

    fn IsoBuilder::add_symlink(self : IsoBuilder, path : String, target : String) -> Unit

    添加一个 Rock Ridge 符号链接(目标按原样写进 SL 条目)。

    IsoBuilder::allow_deep_paths

    fn IsoBuilder::allow_deep_paths(self : IsoBuilder, yes : Bool) -> Unit

    允许写超过 8 层的目录树。ECMA-119 9.4 规定目录层级上限为 8, 深层路径需要 CL/PL 重定位(0.3.0 计划项);默认拒绝,避免产出表面可读、 实则不符合规范的映像。

    IsoBuilder::boot_image

    fn IsoBuilder::boot_image(self : IsoBuilder, path : String, load_sectors : Int, platform : Int) -> Unit

    指定 El Torito 启动映像(必须是已加入的文件路径),生成可启动 ISO。

    IsoBuilder::boot_image_efi

    fn IsoBuilder::boot_image_efi(self : IsoBuilder, path : String, load_sectors : Int) -> Unit

    追加一个 UEFI 启动项(写入启动目录的 section header,平台 0xEF)。

    IsoBuilder::boot_info_table

    fn IsoBuilder::boot_info_table(self : IsoBuilder, yes : Bool) -> Unit

    是否给 BIOS 启动映像写入 boot info table。 syslinux/isolinux 的引导器在启动映像偏移 8 读 56 字节引导参数;不打补丁时 它对 isolinux 类引导器是「看着可启动、实际起不来」。UEFI 启动映像不需要。

    IsoBuilder::build

    fn IsoBuilder::build(self : IsoBuilder) -> Bytes raise IsoError

    生成完整的 ISO 9660 映像字节。

    IsoBuilder::joliet

    fn IsoBuilder::joliet(self : IsoBuilder, enable : Bool) -> Unit

    IsoBuilder::name_level

    fn IsoBuilder::name_level(self : IsoBuilder, level : Int) -> Unit

    设置 ISO 9660 名字级别(1/2/3),影响写入的 ISO 树名字,不影响 Joliet / Rock Ridge 原名。

    IsoBuilder::new

    fn IsoBuilder::new() -> IsoBuilder

    IsoBuilder::rock_ridge

    fn IsoBuilder::rock_ridge(self : IsoBuilder, enable : Bool) -> Unit

    IsoBuilder::rr_version

    fn IsoBuilder::rr_version(self : IsoBuilder, version : Int) -> Unit

    设置 Rock Ridge 版本(109 或 112):1.12 的 PX 记录多 8 字节序列号。

    IsoBuilder::volume_id

    fn IsoBuilder::volume_id(self : IsoBuilder, id : String) -> Unit

    IsoImage

    pub struct IsoImage {
    data : Bytes
    volume_id : String
    block_size : Int
    volume_space_size : Int
    root : DirectoryRecord
    joliet_root : DirectoryRecord?
    joliet_level : Int
    rock_ridge : Bool
    }

    IsoImage::block_size

    fn IsoImage::block_size(self : IsoImage) -> Int

    IsoImage::boot_info

    fn IsoImage::boot_info(self : IsoImage) -> BootInfo? raise IsoError

    El Torito 启动信息;映像不可启动时为 None。

    IsoImage::file_size

    fn IsoImage::file_size(self : IsoImage, path : String) -> Int raise IsoError

    文件大小(多段文件为各段之和)。

    IsoImage::find_record

    fn IsoImage::find_record(self : IsoImage, path : String) -> DirectoryRecord raise IsoError

    按路径查找一条记录(多段文件返回第一段)。

    IsoImage::find_records

    fn IsoImage::find_records(self : IsoImage, path : String) -> Array[DirectoryRecord] raise IsoError

    按路径查找「组成同一实体的连续记录」。

    ISO 9660 的多段文件(flags bit 7 = 1 表示后面还有一段)用同名连续记录描述, 目录永远只有一条记录。

    IsoImage::has_rock_ridge

    fn IsoImage::has_rock_ridge(self : IsoImage) -> Bool

    映像是否带 Rock Ridge 扩展。

    IsoImage::joliet_level

    fn IsoImage::joliet_level(self : IsoImage) -> Int

    Joliet 级别(1/2/3),无 Joliet 时为 0。

    IsoImage::list_dir

    fn IsoImage::list_dir(self : IsoImage, path : String) -> Array[DirectoryRecord] raise IsoError

    列出目录内容(默认过滤掉 . 与 ..),保持映像里的物理顺序。

    IsoImage::open

    fn IsoImage::open(data : Bytes) -> IsoImage raise IsoError

    打开一个 ISO 9660 映像(内存中的完整字节流)。

    IsoImage::read_file

    fn IsoImage::read_file(self : IsoImage, path : String) -> Bytes raise IsoError

    读取文件内容:多段文件按记录顺序拼接,目录以 IsDirectory 失败。 全程做边界检查,越界一律 Truncated,不会读到映像之外。

    IsoImage::read_range

    fn IsoImage::read_range(self : IsoImage, path : String, offset : Int, length : Int) -> Bytes raise IsoError

    区间读取:取文件 [offset, offset+length) 的一段,length 为 0 表示读到结尾。 相比 read_file,大文件不必整块二次拷贝;越界与目录/符号链接同样报错。

    IsoImage::root

    fn IsoImage::root(self : IsoImage) -> DirectoryRecord

    IsoImage::uses_joliet

    fn IsoImage::uses_joliet(self : IsoImage) -> Bool

    是否使用 Joliet 名字(存在补充卷描述符时为真)。

    IsoImage::validate

    fn IsoImage::validate(self : IsoImage) -> ValidationReport

    遍历整棵目录树做结构校验:记录能否解析、extent 是否越界、文件能否读完。 返回全部问题而不是遇错即停,方便一次性给出体检结论。

    IsoImage::volume_id

    fn IsoImage::volume_id(self : IsoImage) -> String

    IsoImage::volume_space_size

    fn IsoImage::volume_space_size(self : IsoImage) -> Int

    IsoImage::walk

    fn IsoImage::walk(self : IsoImage, path : String) -> Array[WalkEntry] raise IsoError

    递归遍历目录树(路径形如 /Docs/note.md,按物理顺序)。

    JolietDescriptor

    pub struct JolietDescriptor {
    level : Int
    root : DirectoryRecord
    }

    Joliet 补充卷描述符。

    PrimaryVolumeDescriptor

    pub struct PrimaryVolumeDescriptor {
    volume_id : String
    volume_space_size : Int
    logical_block_size : Int
    path_table_size : Int
    root : DirectoryRecord
    }

    RecordDate

    pub struct RecordDate {
    year : Int
    month : Int
    day : Int
    hour : Int
    minute : Int
    second : Int
    gmt_offset_quarters : Int
    }

    目录记录的 7 字节时间戳(§9.1.5): 年 = 字段值 + 1900,最后 1 字节是有符号的 15 分钟时区偏移。

    RecordDate::to_iso_string

    fn RecordDate::to_iso_string(self : RecordDate) -> String

    RockRidge

    pub struct RockRidge {
    name : String?
    mode : Int?
    symlink : String?
    present : Bool
    }

    UdfEntry

    pub struct UdfEntry {
    name : String
    is_dir : Bool
    size : Int
    }

    UDF 目录项。

    UdfExtent

    pub struct UdfExtent {
    length : Int
    location : Int
    partition : Int
    }

    长分配描述符(long_ad):长度、逻辑块号、分区引用号。

    UdfImage

    pub struct UdfImage {
    data : Bytes
    block_size : Int
    partition_start : Int
    root : UdfExtent
    }

    UDF 映像。

    UdfImage::block_size

    fn UdfImage::block_size(self : UdfImage) -> Int

    UdfImage::list_dir

    fn UdfImage::list_dir(self : UdfImage, path : String) -> Array[UdfEntry] raise IsoError

    列出一级目录。

    UdfImage::open

    fn UdfImage::open(data : Bytes) -> UdfImage raise IsoError

    打开 UDF 映像;不是 UDF(没有有效 Anchor)时以 BadDescriptor 失败。

    UdfImage::read_file

    fn UdfImage::read_file(self : UdfImage, path : String) -> Bytes raise IsoError

    读取文件内容。

    ValidationReport

    pub struct ValidationReport {
    directories : Int
    files : Int
    symlinks : Int
    total_bytes : Int
    problems : Array[String]
    }

    结构校验结果。

    WalkEntry

    pub struct WalkEntry {
    path : String
    is_dir : Bool
    is_symlink : Bool
    size : Int
    }

    遍历结果的一项。

    SECTOR_SIZE

    let SECTOR_SIZE : Int

    VOLUME_DESCRIPTOR_START_LBA

    let VOLUME_DESCRIPTOR_START_LBA : Int

    block_offset

    fn block_offset(block : Int, block_size : Int, limit : Int) -> Int raise IsoError

    把逻辑块号换算成字节偏移。用 64 位中间量:32 位乘法会回绕, 回绕后仍可能落进映像范围,从而"读出错误数据"而不是报错。

    decode_ucs2_be

    fn decode_ucs2_be(raw : Bytes) -> String

    解码 Joliet 的 UCS-2 大端名字(含非 BMP 的代理对),遇到 NUL 结束。

    extent_offset

    fn extent_offset(block : Int, size : Int, block_size : Int, limit : Int) -> Int raise IsoError

    校验 [blockblock_size, blockblock_size+size) 落在映像内,返回字节偏移。

    find_boot_catalog_lba

    fn find_boot_catalog_lba(data : Bytes) -> Int? raise IsoError

    在卷描述符链里找启动记录卷描述符(类型 0),返回启动目录所在的逻辑块号。

    find_joliet_descriptor

    fn find_joliet_descriptor(data : Bytes) -> JolietDescriptor? raise IsoError

    查找 Joliet 补充卷描述符:类型 2,偏移 88 的转义序列为 %/@、%/C 或 %/E。

    normalize_iso_name

    fn normalize_iso_name(raw : String) -> String

    去掉 ISO 9660 的 ;版本号,并去掉「无扩展名」时残留的点号。

    normalize_path

    fn normalize_path(path : String) -> String

    规整路径:保证以 / 开头、去掉结尾 /、折叠重复 /。

    parse_boot_catalog

    fn parse_boot_catalog(data : Bytes, catalog_lba : Int) -> BootInfo raise IsoError

    解析 El Torito 启动目录:校验项 + 第一个启动项。

    parse_directory_record

    fn parse_directory_record(reader : ByteReader) -> (DirectoryRecord, Int) raise IsoError

    解析一条 ISO 9660(ASCII 名字)目录记录。

    parse_directory_record_in

    fn parse_directory_record_in(reader : ByteReader, joliet : Bool) -> (DirectoryRecord, Int) raise IsoError

    从 reader 当前位置解析一条目录记录,返回记录本身与消耗的字节数。

    joliet 为 true 时名字按 UCS-2 大端解码(补充卷描述符里的记录)。 返回长度为 0 表示目录数据在本扇区后面是填充。

    parse_primary_volume_descriptor

    fn parse_primary_volume_descriptor(data : Bytes, lba : Int) -> PrimaryVolumeDescriptor raise IsoError

    解析主卷描述符(类型 1)。

    parse_rock_ridge

    fn parse_rock_ridge(data : Bytes, block_size : Int, system_use : Bytes) -> RockRidge raise IsoError

    解析一条记录的 system use area,得到 Rock Ridge 信息。

    parse_susp

    fn parse_susp(data : Bytes, block_size : Int, area : Bytes, info : RockRidge, depth : Int) -> Unit raise IsoError

    解析一段 SUSP 条目流,把结果累加到 info 上。

    data / block_size 用于跟随 CE 续接区;depth 限制续接层数,防止畸形映像造成死循环。

    scan_volume_descriptors

    fn scan_volume_descriptors(data : Bytes) -> Array[(Int, Int)] raise IsoError

    扫描卷描述符链,返回 (类型, 扇区号) 列表,直到遇到结束符。 结构不完整(没有结束符)视为损坏。