If I wanted to insert a bytes like object
bazstr = b'bazzzzzz\n'
Into an iso how would I go about doing that in python?
f=open("/Users/root/Downloads/archlinux-2019.08.01-x86_64.iso",'w+')
f.buffer.raw.read()
This used up too much memory and almost caused a freeze.
f.buffer.raw.readline('''any number''')
f.buffer.readline('''any number''')
f.readline('''any number''')
# All returned no bytes
f.read(#)
f=open("/Users/root/Downloads/archlinux-2019.08.01-x86_64.iso",'rb')
#returns bytes but but doesn't allow searching through the iso in a meaningful way.
I don't want to just open blocks of bytes I want to use python to open the file system of the ISO look around at the files edit some of them then have an image that I didn't destroy.
As I was creating this question I located the answer. Main Git This python library has ISO writing functionality. Which is exactly what I was looking for. Full Doc and Example
try:
from cStringIO import StringIO as BytesIO
except ImportError:
from io import BytesIO
import pycdlib
iso = pycdlib.PyCdlib()
iso.new()
foostr = b'foo\n'
iso.add_fp(BytesIO(foostr), len(foostr), '/FOO.;1')
outiso = BytesIO()
iso.write_fp(outiso)
iso.close()
iso.open_fp(outiso)
bazstr = b'bazzzzzz\n'
iso.modify_file_in_place(BytesIO(bazstr), len(bazstr), '/FOO.;1')
modifiediso = BytesIO()
iso.write_fp(modifiediso)
iso.close()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With