Skip to content

Cuebin archiver - #128

Open
tomaz82 wants to merge 3 commits into
icculus:mainfrom
tomaz82:cuebin-archiver
Open

tomaz82 wants to merge 3 commits into
icculus:mainfrom
tomaz82:cuebin-archiver

Conversation

@tomaz82

@tomaz82 tomaz82 commented Oct 14, 2026

Copy link
Copy Markdown
  • I confirm that I am the author of this code and release it to the PhysicsFS project under the zlib license. This contribution does not contain code from other sources, including code generated by a Large Language Model ("AI").

This PR adds a basic CUE+BIN archiver to PhysicsFS, which has been mainly tested on PlayStation 1 mixed-mode multi-bin images.

The archiver parses the .cue sheet to build an internal file/track list, and then hands over the heavy lifting to the built-in ISO9660 archiver.

Due to PlayStation 1 developers adding the raw audio tracks as "fake" files directly into the Track 1 (DATA) track file tree, the entries inherit incorrect metadata properties:

  • The ISO filesystem layer expects standard data sectors (2048 bytes). However, AUDIO tracks store the files across the entire physical sector (2352 bytes).
  • This structural conflict causes the file entries to store the completely wrong file size and starting position inside the virtual tree.

To resolve this, the archiver intercepts the layout tree immediately after the core ISO9660 loader finishes parsing.

  • It executes a post-filter recursive tree walk (cuebinPatchTree) across the loaded UNPK structures in memory.
  • It cross-references file offsets against the track map to recalculate both the file sizes and the start positions for any files mapped onto the raw audio track sectors.
  • This updates the file dimensions directly in memory before the container is finalized, allowing downstream loops to read the full audio payloads without truncation or seek tracking drift.

I based the entire thing on the code style in the ISO archiver but due to it being very different from my personal code style it might be off at places.

This PR does not do anything with the audio tracks in the case where they are not faked into the DATA track. Standard separate CD-DA audio track data streams are skipped by the file post-filter.

This also includes a fix found elsewhere in one of the issues here, and that is to just ignore dir entries that goes nowhere (points to itself?) instead of bailing.

Feel free to ask any questions, altho I hope the code is written in a way that makes it self explanatory.

@tomaz82
tomaz82 force-pushed the cuebin-archiver branch 2 times, most recently from 48c5f82 to 127e7c0 Compare October 14, 2026 14:24
@sezero

sezero commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator

Patch to remove c99-isms: c90.patch

@tomaz82

tomaz82 commented Oct 14, 2026

Copy link
Copy Markdown
Author

Patch to remove c99-isms: c90.patch

Sorry for that, should be fixed now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants