fix: mount .bin directly instead of .cue to avoid case mismatch
Build & Deploy / build-and-deploy (push) Successful in 39s

.cue files contain an internal FILE reference (e.g. FILE "z.BIN")
that may not match the actual filename on disk (e.g. z.bin) due to
case differences. In js-dos's case-sensitive WASM filesystem, this
causes the imgmount to fail silently.

Changes:
- Added .bin to CD_EXT so findCdImages detects bin files
- When both .cue and .bin exist in the same directory, only the
  .bin is mounted (with -fs iso flag for direct filesystem access)
- .cue files without a matching .bin are still mounted as before
- Deduplication prevents mounting both .cue and .bin from same dir
This commit is contained in:
Hermes Agent
2026-06-03 09:45:04 +02:00
parent 4a3ba3b986
commit de9e978e55
@@ -391,7 +391,7 @@ public class UploadResource {
/** File extensions that DOSBox can mount as CD-ROM via imgmount. */ /** File extensions that DOSBox can mount as CD-ROM via imgmount. */
private static final java.util.Set<String> CD_EXT = java.util.Set.of( private static final java.util.Set<String> CD_EXT = java.util.Set.of(
".iso", ".cue", ".img", ".ccd" ".iso", ".cue", ".img", ".ccd", ".bin"
); );
/** Find mountable CD image files in the extracted game directory. /** Find mountable CD image files in the extracted game directory.
@@ -584,10 +584,30 @@ public class UploadResource {
sb.append("[autoexec]\n"); sb.append("[autoexec]\n");
sb.append("@echo off\n"); sb.append("@echo off\n");
sb.append("mount c .\n"); sb.append("mount c .\n");
// Mount CD images as D:, E:, … so games can find their CD // Mount CD images as D:, E:, … so games can find their CD.
// Prefer .bin over .cue from the same directory to avoid case-mismatch
// between the .cue's internal FILE reference and the actual filename.
// .bin files are mounted with -fs iso for direct filesystem access.
Set<String> seenDirs = new java.util.HashSet<>();
char driveLetter = 'D'; char driveLetter = 'D';
for (String img : cdImages) { for (String img : cdImages) {
sb.append("imgmount ").append(driveLetter).append(" \"").append(img).append("\" -t cdrom\n"); // Deduplicate by directory — prefer .bin over .cue
int slashIdx = img.lastIndexOf('/');
String parentDir = slashIdx >= 0 ? img.substring(0, slashIdx) : "";
String imgLower = img.toLowerCase();
if (seenDirs.contains(parentDir)) continue;
if (imgLower.endsWith(".cue")) {
// Check if a .bin exists in the same directory
boolean hasBin = cdImages.stream().anyMatch(i -> {
int is = i.lastIndexOf('/');
String ip = is >= 0 ? i.substring(0, is) : "";
return ip.equals(parentDir) && i.toLowerCase().endsWith(".bin");
});
if (hasBin) continue; // .bin will be mounted instead (lower in list)
}
seenDirs.add(parentDir);
String flags = imgLower.endsWith(".bin") ? " -t cdrom -fs iso" : " -t cdrom";
sb.append("imgmount ").append(driveLetter).append(" \"").append(img).append("\"").append(flags).append("\n");
driveLetter++; driveLetter++;
} }
sb.append("c:\n"); sb.append("c:\n");