pycdlib icon indicating copy to clipboard operation
pycdlib copied to clipboard

Implement file ordering/pycdlib-genisoimage's -sort option?

Open boringhexi opened this issue 5 years ago • 2 comments

Currently, pycdlib-genisoimage does not support the -sort option, and as I understand it, internally pycdlib assigns extents in the order it walks through the file paths. While I don't use pycdlib-genisoimage directly, the ability to manually order files would be useful for an application I'm writing.

The use case: Editing a PS2 game's ISO image, preserving file order so that I can create an xdelta patch between the original ISO and the edited ISO.

As such, I was thinking about making a personal fork of pycdlib that just does what I need it to do. But if you have plans to implement file ordering, then maybe I'm better off waiting for that (and helping out if that's something I can contribute to).

edit: I'm aware of modify_file_in_place, which will work for some cases, but often I will need to replace a smaller file with a larger one.

boringhexi avatar Jan 26 '20 07:01 boringhexi

Currently, pycdlib-genisoimage does not support the -sort option, and as I understand it, internally pycdlib assigns extents in the order it walks through the file paths.

Yep, it just walks the directory structure from the root in breadth-first fashion, assigning extents as it goes along. Note that opening an ISO and then writing it back out will replicate the extent assignments that are already there (since we never do reassignments in that case), but any edit will potentially cause them all to be reassigned.

The use case: Editing a PS2 game's ISO image, preserving file order so that I can create an xdelta patch between the original ISO and the edited ISO.

One way to do this would indeed be using a genisoimage-like sort option. But I think that might be difficult to use. Another idea here is to add an option to open() which is something like preserve_extent_order, which would attempt to preserve the extent order instead of reassigning everything.

As such, I was thinking about making a personal fork of pycdlib that just does what I need it to do. But if you have plans to implement file ordering, then maybe I'm better off waiting for that (and helping out if that's something I can contribute to).

I don't have any immediate plans to implement either of the ideas above. I would definitely be happy to review pull requests that implement them.

clalancette avatar Jan 26 '20 13:01 clalancette

+1, this would be a godsend for PS2 ISOs and fan translators (like myself) who rely on GUI software like Xpert2 to dump and rebuild PS2 ISOs in order to create xDelta patches.

Also, since there are only GUI tools to dump and rebuild PS2 ISOs, its kinda a pain in the ass to create translation pipelines that interacts with a GUI.

Risae avatar Aug 21 '22 17:08 Risae