python: edit ISO file directly

本小妞迷上赌 提交于 2019-11-30 15:47:09
  1. Of course, as with any file.

  2. It can be done with open/read/write/seek/tell/close operations on a file. Pack/unpack the data with struct/ctypes. It would require serious knowledge of the contents of ISO, but I presume you already know what to do. If you're lucky you can try using mmap - the interface to file contents string-like.

Have you seen Hachoir, a Python library to "view and edit a binary stream field by field"? I haven't had a need to try it myself, but ISO 9660 is listed as a supported parser format.

You can use for listing and extracting, I tested the first.

https://github.com/barneygale/iso9660/blob/master/iso9660.py

import iso9660
cd = iso9660.ISO9660("/Users/murat/Downloads/VisualStudio6Enterprise.ISO")
for path in cd.tree():
    print path

https://github.com/barneygale/isoparser

import isoparser
iso = isoparser.parse("http://www.microsoft.com/linux.iso")

print iso.record("boot", "grub").children
print iso.record("boot", "grub", "grub.cfg").content
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!