Skip to content

exe2iso: rewrite on top of the ISO9660 builder#2036

Open
nicolasnoble wants to merge 1 commit into
grumpycoders:mainfrom
nicolasnoble:exe2iso-isobuilder
Open

exe2iso: rewrite on top of the ISO9660 builder#2036
nicolasnoble wants to merge 1 commit into
grumpycoders:mainfrom
nicolasnoble:exe2iso-isobuilder

Conversation

@nicolasnoble

Copy link
Copy Markdown
Member

exe2iso predates the supportpsx ISO9660 authoring API and hand-rolled a minimal, non-conformant disc image just barely good enough for the BIOS to boot. Now that the builder exists, use it: the output is a proper ISO9660 filesystem with a single PSX.EXE;1 in the root, valid EDC/ECC on every sector, and the PLAYSTATION system identifier in the PVD.

This drops the options the builder makes meaningless: -regen (EDC/ECC is always computed now), -offset (a real filesystem places the file), and the undocumented -data. Padding stays, but now defaults on with a -nopad opt-out, since writing to an actual disc is the case that wants it.

exe2iso predates the supportpsx ISO9660 authoring API and hand-rolled a
minimal, non-conformant disc image just barely good enough for the BIOS to
boot. Now that the builder exists, use it: the output is a proper ISO9660
filesystem with a single PSX.EXE;1 in the root, valid EDC/ECC on every
sector, and the PLAYSTATION system identifier in the PVD.

This drops the options the builder makes meaningless: -regen (EDC/ECC is
always computed now), -offset (a real filesystem places the file), and the
undocumented -data. Padding stays, but now defaults on with a -nopad
opt-out, since writing to an actual disc is the case that wants it.

Signed-off-by: Nicolas 'Pixel' Noble <nicolas@nobis-crew.org>
@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

exe2iso is refactored to generate ISO images via PCSX::ISO9660Builder/PCSX::ISO9660LowLevel instead of manual sector construction. CLI flags are revised: -offset, -pad, and -regen are removed; -nopad and -license are added. Both README files are updated to reflect conformant ISO9660 output.

Changes

exe2iso refactor to ISO9660Builder

Layer / File(s) Summary
CLI flags, file handling, and includes
tools/exe2iso/exe2iso.cc
Replaces low-level includes with ISO9660 builder headers and adds c_trailingPaddingSectors = 150; rewrites argument parsing to support -license, -nopad, -h while removing -offset/-pad/-regen; switches file I/O to PCSX::IO wrappers with simplified error handling.
ISO9660 image construction and trailing padding
tools/exe2iso/exe2iso.cc
Constructs the ISO via PCSX::ISO9660Builder: sets PVD system identifier to "PLAYSTATION", writes license area, creates root directory, adds PSX.EXE, finalizes with builder.close(); then optionally appends c_trailingPaddingSectors zeroed M2_FORM1 sectors.
Documentation updates
tools/README.md, tools/exe2iso/README.md
Updates top-level tool listing and the exe2iso-specific README to describe standards-conformant ISO9660 output, revising the usage synopsis and arguments table to match the new flag set.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 Hoppity-hop through sectors no more,
The ISO9660 builder takes the floor!
No manual ECC, no bespoke byte art —
Just PSX.EXE;1, conformant from the start.
The rabbit stamps "valid" with a satisfied thump,
Standards rejoice with a celebratory jump! 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'exe2iso: rewrite on top of the ISO9660 builder' accurately summarizes the main change—refactoring exe2iso to use the ISO9660 builder API instead of manual disc image generation.
Description check ✅ Passed The description clearly explains the motivation (existing builder API), what changed (proper ISO9660 filesystem with valid EDC/ECC), and which options were removed or modified, directly relating to the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tools/exe2iso/exe2iso.cc`:
- Around line 51-62: The condition at line 51 combines the help flag check with
usage error checks, causing the help message to exit with -1 (failure) instead
of 0 (success). Refactor the logic to check asksForHelp separately first: if
true, print the help message and return 0, then check the remaining conditions
(hasExactlyOneInput and hasOutput) separately and only return -1 if those
validations fail. This ensures that requesting help with the -h flag exits
successfully while actual usage errors still indicate failure.

In `@tools/exe2iso/README.md`:
- Around line 10-12: The markdown linter rule MD058 (blanks-around-tables)
requires a blank line before table content. In the README.md file, add a blank
line between the usage example line starting with "Usage: exe2iso input.ps-exe"
and the table header row that starts with "| Argument". This blank line
separation is necessary to satisfy the markdownlint requirements for proper
table formatting.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 540893e4-69a4-41be-aae5-10a7573a42f8

📥 Commits

Reviewing files that changed from the base of the PR and between e2b4d90 and 28b5456.

📒 Files selected for processing (3)
  • tools/README.md
  • tools/exe2iso/README.md
  • tools/exe2iso/exe2iso.cc

Comment thread tools/exe2iso/exe2iso.cc
Comment on lines +51 to 62
if (asksForHelp || !hasExactlyOneInput || !hasOutput) {
fmt::print(R"(
Usage: {} input.ps-exe [-offset value] [-pad] [-regen] [-license file] -o output.bin
Usage: {} input.ps-exe [-license file] [-nopad] -o output.bin
input.ps-exe mandatory: specify the input ps-exe file.
-o output.bin mandatory: name of the output file.
-offset value optional: move the exe data by value sectors.
-data filename optional: insert this file into the iso after the exe.
-pad optional: pads the iso with 150 blank sectors.
-regen optional: generates proper ECC/EDC.
-license file optional: use this license file.
-nopad optional: don't append {} trailing blank sectors.
-h displays this help information and exit.
)",
argv[0]);
argv[0], c_trailingPaddingSectors);
return -1;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Return success when -h is requested.

Line 51 currently routes help requests and invalid-usage errors through the same branch, so -h exits with -1. That makes help look like a failure in scripts/CI.

🔧 Suggested fix
-    if (asksForHelp || !hasExactlyOneInput || !hasOutput) {
+    if (asksForHelp) {
+        fmt::print(R"(
+Usage: {} input.ps-exe [-license file] [-nopad] -o output.bin
+  input.ps-exe      mandatory: specify the input ps-exe file.
+  -o output.bin     mandatory: name of the output file.
+  -license file     optional: use this license file.
+  -nopad            optional: don't append {} trailing blank sectors.
+  -h                displays this help information and exit.
+)",
+                   argv[0], c_trailingPaddingSectors);
+        return 0;
+    }
+
+    if (!hasExactlyOneInput || !hasOutput) {
         fmt::print(R"(
 Usage: {} input.ps-exe [-license file] [-nopad] -o output.bin
   input.ps-exe      mandatory: specify the input ps-exe file.
@@
 )",
                    argv[0], c_trailingPaddingSectors);
         return -1;
     }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tools/exe2iso/exe2iso.cc` around lines 51 - 62, The condition at line 51
combines the help flag check with usage error checks, causing the help message
to exit with -1 (failure) instead of 0 (success). Refactor the logic to check
asksForHelp separately first: if true, print the help message and return 0, then
check the remaining conditions (hasExactlyOneInput and hasOutput) separately and
only return -1 if those validations fail. This ensures that requesting help with
the -h flag exits successfully while actual usage errors still indicate failure.

Comment thread tools/exe2iso/README.md
Comment on lines +10 to 12
Usage: exe2iso input.ps-exe [-license file] [-nopad] -o output.bin
| Argument | Type | Description |
|-|-|-|

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Add a blank line before the table to satisfy markdownlint.

Line 11 triggers MD058 (blanks-around-tables). Add an empty line between the usage line and the table header.

📝 Suggested fix
 Usage: exe2iso input.ps-exe [-license file] [-nopad] -o output.bin
+
 | Argument | Type | Description |
 |-|-|-|
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Usage: exe2iso input.ps-exe [-license file] [-nopad] -o output.bin
| Argument | Type | Description |
|-|-|-|
Usage: exe2iso input.ps-exe [-license file] [-nopad] -o output.bin
| Argument | Type | Description |
|-|-|-|
🧰 Tools
🪛 markdownlint-cli2 (0.22.1)

[warning] 11-11: Tables should be surrounded by blank lines

(MD058, blanks-around-tables)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tools/exe2iso/README.md` around lines 10 - 12, The markdown linter rule MD058
(blanks-around-tables) requires a blank line before table content. In the
README.md file, add a blank line between the usage example line starting with
"Usage: exe2iso input.ps-exe" and the table header row that starts with "|
Argument". This blank line separation is necessary to satisfy the markdownlint
requirements for proper table formatting.

Source: Linters/SAST tools

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant