Skip to content

fix: match a cuesheet's filename however it is capitalised - #67

Merged
casmith merged 1 commit into
mainfrom
fix/cuesheet-filename-case
Sep 5, 2026
Merged

fix: match a cuesheet's filename however it is capitalised#67
casmith merged 1 commit into
mainfrom
fix/cuesheet-filename-case

Conversation

@casmith

@casmith casmith commented Sep 5, 2026

Copy link
Copy Markdown
Owner

Three Final Fantasy VII discs failed to install:

Failed  convert Final Fantasy VII Disc 1.cue: invalid cuesheet:
        Final Fantasy VII Disc 1.cue references FINAL FANTASY VII DISC 1.BIN, which is missing

against a file plainly sitting right there. The archive holds:

Final Fantasy VII [Disc1of3] [U] [SCUS-94163]/Final Fantasy VII Disc 1.bin
Final Fantasy VII [Disc1of3] [U] [SCUS-94163]/Final Fantasy VII Disc 1.cue

and the sheet — a 2003 rip — says:

FILE "FINAL FANTASY VII DISC 1.BIN" BINARY
  TRACK 01 MODE2/2352
    INDEX 01 00:00:00

Cuesheets are routinely written on Windows, where the case of a filename carries no information. The rip is fine; it works everywhere except a case-sensitive filesystem.

Change

A FILE reference now falls back to a case-insensitive match within the sheet's own directory.

  • The exact name always wins, and the directory is only read when the exact name doesn't resolve — so nothing gets slower, and no ambiguity is introduced where the filesystem itself has none.
  • A name matching nothing is returned unchanged, so the error still quotes what the sheet actually said.
  • BinName keeps the name as written: that is what an error should quote and what an archive listing agrees with. Only the resolved path changes.

A quieter symptom it also fixes

The scanner excludes the tracks a cuesheet names, so that one rip is one title rather than several files. That exclusion is by path — so a sheet whose case didn't match left its .bin unexcluded and listed as a title of its own, beside the game it belongs to.

Scope

Only the on-disk path was affected. Inside an archive the data track is chosen from the listing rather than by name, which is why these titles scanned correctly and only failed at conversion.

Tests

  • TestParseCueFileMatchesTheFilenameCaseInsensitively uses the real sheet's exact contents and filename. Mutation-checked: removing the fallback compiles and fails it with the user's error verbatim — references FINAL FANTASY VII DISC 1.BIN, which is missing.
  • TestParseCueFilePrefersTheExactFilename — two files differing only in case still resolve to the one named.
  • TestParseCueFileStillReportsAMissingTrack — a genuinely absent file is still reported, quoting the sheet's name.

Also checked against the real cuesheet extracted from the archive: FINAL FANTASY VII DISC 1.BIN resolves to Final Fantasy VII Disc 1.bin and validates.

Full suite, go vet, gofmt and scripts/demo-smoke.sh pass.

https://claude.ai/code/session_018eBAB3V9GRxNwgpQcpGje4

Three Final Fantasy VII discs failed to install with

  invalid cuesheet: Final Fantasy VII Disc 1.cue references
  FINAL FANTASY VII DISC 1.BIN, which is missing

against a file the user could plainly see was there. The rip is from
2003 and its sheet says

  FILE "FINAL FANTASY VII DISC 1.BIN" BINARY

beside a file called "Final Fantasy VII Disc 1.bin". Cuesheets are
routinely written on Windows, where the case of a filename is not
information, so this rip works everywhere except a case-sensitive
filesystem.

A FILE reference now falls back to a case-insensitive match in the
sheet's own directory. The exact name always wins and the directory is
only read when the exact name does not resolve, so nothing is slower and
no ambiguity is introduced where the filesystem itself has none. A name
that matches nothing is returned unchanged, so the error still quotes
what the sheet actually said.

BinName keeps the name as written, because that is what an error should
quote and what an archive's own listing agrees with; only the resolved
path changes.

This also fixes a quieter symptom. The scanner excludes the tracks a
cuesheet names so that one rip is one title, and that exclusion is by
path -- so a sheet whose case did not match left its .bin unexcluded and
listed as a title of its own, beside the game it belongs to.

Only the on-disk path was affected. Inside an archive the data track is
chosen from the listing rather than by name, which is why these titles
scanned correctly and then failed at conversion.

Claude-Session: https://claude.ai/code/session_018eBAB3V9GRxNwgpQcpGje4
@casmith
casmith merged commit ea44b1b into main Sep 5, 2026
5 checks passed
@casmith
casmith deleted the fix/cuesheet-filename-case branch September 5, 2026 16:47
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.

1 participant