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
|
new_record.inode.data_length = iso_file_length - extent_to_use * self.logical_block_size |
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
pycdlib/pycdlib/pycdlib.py
Line 1109 in 2732b6b
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?