mirror of
https://github.com/scummvm/scummvm.git
synced 2026-05-21 05:40:43 +00:00
09cff5ecc0
tag v1.15.0 67fe5ea7f68cf1185379c2c5e8acf37d483a2d4a https://github.com/clalancette/pycdlib.git
41 lines
1.2 KiB
Python
41 lines
1.2 KiB
Python
# This is program to show how to use PyCdlib to create a new ISO that is
|
|
# bootable.
|
|
|
|
# Import standard python modules.
|
|
import sys
|
|
try:
|
|
from cStringIO import StringIO as BytesIO
|
|
except ImportError:
|
|
from io import BytesIO
|
|
|
|
# Import pycdlib itself.
|
|
import pycdlib
|
|
|
|
# Check that there are enough command-line arguments.
|
|
if len(sys.argv) != 1:
|
|
print('Usage: %s' % (sys.argv[0]))
|
|
sys.exit(1)
|
|
|
|
# Create a new PyCdlib object.
|
|
iso = pycdlib.PyCdlib()
|
|
|
|
# Create a new ISO, accepting all of the defaults.
|
|
iso.new()
|
|
|
|
# Add a new file to the ISO, with the contents coming from the file object.
|
|
# This file will be used as the boot file on the bootable ISO.
|
|
bootstr = b'boot\n'
|
|
iso.add_fp(BytesIO(bootstr), len(bootstr), '/BOOT.;1')
|
|
|
|
# Once the bootable file is on the ISO, we need to link it to the boot catalog
|
|
# by calling add_eltorito.
|
|
iso.add_eltorito('/BOOT.;1', bootcatfile='/BOOT.CAT;1')
|
|
|
|
# Write out the ISO to the file called 'eltorito.iso'. This will fully master
|
|
# the ISO, making it bootable.
|
|
iso.write('eltorito.iso')
|
|
|
|
# Close the ISO object. After this call, the PyCdlib object has forgotten
|
|
# everything about the previous ISO, and can be re-used.
|
|
iso.close()
|