1234567891011121314151617181920212223242526272829303132333435 |
- #!/usr/bin/env kuroko
- import fileio
- from util import ISO, FAT
- let image = ISO('image.iso')
- let fat = image.root.find('FAT.IMG')
- let fatfs = FAT(image, fat.extent_start_lsb * image.sector_size)
- def process(fatfile, path):
- if fatfile.is_long():
- return
- if fatfile.readable_name() == '.':
- return
- if fatfile.readable_name() == '..':
- return
- if fatfile.is_dir():
- for i in fatfile.to_dir().list():
- process(i, path + fatfile.readable_name() + '/')
- else:
- let cdfile = image.get_file(path + fatfile.readable_name())
- if not cdfile:
- if fatfile.readable_name() != 'bootia32.efi' and fatfile.readable_name() != 'bootx64.efi':
- print("Warning:", fatfile.readable_name(), "not found in ISO")
- else:
- cdfile.extent_start_lsb = fatfile.get_offset() // 2048
- cdfile.extent_length_lsb = fatfile.filesize
- cdfile.write_extents()
- for i in fatfs.root.list():
- process(i,'/')
- with fileio.open('image.iso','wb') as f:
- f.write(bytes(image.data))
|