Mercurial > lcfOS
view python/iso9660.py @ 284:05184b95fa16
Moved tests to seperate folder
author | Windel Bouwman |
---|---|
date | Fri, 15 Nov 2013 13:43:22 +0100 |
parents | c9781c73e7e2 |
children | 1c7c1e619be8 |
line wrap: on
line source
import argparse """ ISO 9660 filesystem utility. """ def read_vol_desc(f): s = f.read(2048) ty = s[0] Id = s[1:6] assert Id == 'CD001'.encode('ascii') ver = s[6] assert ver == 1 data = s[7:] assert len(data) == 2041 return ty, Id, s def parse_boot_record(sec): boot_sys_id = sec[7:39] boot_id = sec[39:71] print(boot_sys_id) print(boot_id) def parse_primary_volume(sec): sys_id = sec[8:40] vol_id = sec[40:72] print(sys_id) print(vol_id) def read_iso(f): # System area system = f.read(16 * 2048) while True: ty, Id, dat = read_vol_desc(f) print(ty, Id) if ty == 255: break elif ty == 0: parse_boot_record(dat) elif ty == 1: parse_primary_volume(dat) if __name__ == '__main__': with open('mikeos.iso', 'rb') as f: read_iso(f)