I was trying to write a script to verify the correctness of iso files. Most importantly to find out if they were truncated. My idea was to extract each file and compare with the expected file size.
However I think this line
https://github.com/clalancette/pycdlib/blob/2732b6bd86a52a47263f662f98f89d94bbd62a7c/pycdlib/pycdlib.py#L1109
prevents me from doing so as it "helpfully" "fixes" the filesize in exactly this case.
If I comment out this line it's working.
iso = PyCdlib()
try:
iso.open(path)
try:
for basepath, dirlist, filelist in iso.walk(iso_path="/"):
for filename in filelist:
path = f"{basepath}/{filename}"
record = iso.get_record(iso_path=path)
if not record.is_symlink() and record.is_file():
with open(os.devnull, "wb") as fw:
iso.get_file_from_iso_fp(fw, iso_path=path)
if record.get_data_length() != fw.tell():
raise RuntimeError("truncated file")
finally:
iso.close()
except PyCdlibInvalidISO as e:
raise RuntimeError("broken file")
Is there some way to achieve this without modifying the library?
I was trying to write a script to verify the correctness of iso files. Most importantly to find out if they were truncated. My idea was to extract each file and compare with the expected file size. However I think this line https://github.com/clalancette/pycdlib/blob/2732b6bd86a52a47263f662f98f89d94bbd62a7c/pycdlib/pycdlib.py#L1109 prevents me from doing so as it "helpfully" "fixes" the filesize in exactly this case. If I comment out this line it's working.
Is there some way to achieve this without modifying the library?