From 8a45ceccdc4f0909ba21d6966259fee838ed40af Mon Sep 17 00:00:00 2001 From: Hermes Agent Date: Wed, 3 Jun 2026 12:36:14 +0200 Subject: [PATCH] fix: prefer descriptor formats (.cue/.ccd) over raw data (.img/.bin) for DOSBox CD mounting DOSBox's imgmount works best with descriptors because they contain track layout info (audio tracks, subchannel data, copy protection). Raw .img/.bin mounts lose this info, making the filesystem inaccessible and causing 'Illegal command' when trying to run executables from the CD. --- .../java/com/dostalgia/UploadResource.java | 33 +++++++++++-------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/dostalgia/UploadResource.java b/src/main/java/com/dostalgia/UploadResource.java index ac32106..af22e34 100644 --- a/src/main/java/com/dostalgia/UploadResource.java +++ b/src/main/java/com/dostalgia/UploadResource.java @@ -574,6 +574,8 @@ public class UploadResource { sb.append("[dos]\nxms=true\nems=true\numb=true\n\n"); sb.append("[autoexec]\n@echo off\nmount c .\n"); // Mount CD images as D:, E:, … + // Prefer descriptor formats (.cue, .ccd) over raw data (.img, .bin) + // DOSBox needs descriptors for proper track layout and filesystem access. Set seenDirs = new java.util.HashSet<>(); char driveLetter = 'D'; for (String img : cdImages) { @@ -581,19 +583,20 @@ public class UploadResource { String parentDir = slashIdx >= 0 ? img.substring(0, slashIdx) : ""; if (seenDirs.contains(parentDir)) continue; String imgLower = img.toLowerCase(); - // Skip descriptor formats if a data format exists in the same directory - if (imgLower.endsWith(".cue") || imgLower.endsWith(".ccd")) { - boolean hasData = cdImages.stream().anyMatch(i -> { + // Skip raw data files when a descriptor exists in the same directory + if (imgLower.endsWith(".img") || imgLower.endsWith(".bin")) { + boolean hasDescriptor = cdImages.stream().anyMatch(i -> { int is = i.lastIndexOf('/'); String ip = is >= 0 ? i.substring(0, is) : ""; String il = i.toLowerCase(); return ip.equals(parentDir) - && (il.endsWith(".img") || il.endsWith(".iso") || il.endsWith(".bin")); + && (il.endsWith(".cue") || il.endsWith(".ccd")); }); - if (hasData) continue; + if (hasDescriptor) continue; } seenDirs.add(parentDir); - String flags = imgLower.endsWith(".bin") ? " -t cdrom -fs iso" : " -t cdrom"; + String flags = (imgLower.endsWith(".bin") && !imgLower.endsWith(".cue")) + ? " -t cdrom -fs iso" : " -t cdrom"; sb.append("imgmount ").append(driveLetter).append(" \"").append(img).append("\"").append(flags).append("\n"); driveLetter++; } @@ -651,8 +654,9 @@ public class UploadResource { sb.append("@echo off\n"); sb.append("mount c .\n"); // Mount CD images as D:, E:, … so games can find their CD. - // Deduplicate by parent directory — prefer data formats (.img, .iso, .bin) - // over descriptor formats (.cue, .ccd) which can have FILE path case-mismatch. + // Deduplicate by parent directory — prefer descriptor formats (.cue, .ccd) + // over raw data formats (.img, .bin). DOSBox needs descriptors for proper + // track layout (audio tracks, subchannel data, copy protection). Set seenDirs = new java.util.HashSet<>(); char driveLetter = 'D'; for (String img : cdImages) { @@ -660,19 +664,20 @@ public class UploadResource { String parentDir = slashIdx >= 0 ? img.substring(0, slashIdx) : ""; if (seenDirs.contains(parentDir)) continue; String imgLower = img.toLowerCase(); - // Skip descriptor formats if a data format exists in the same directory - if (imgLower.endsWith(".cue") || imgLower.endsWith(".ccd")) { - boolean hasData = cdImages.stream().anyMatch(i -> { + // Skip raw data files when a descriptor exists in the same directory + if (imgLower.endsWith(".img") || imgLower.endsWith(".bin")) { + boolean hasDescriptor = cdImages.stream().anyMatch(i -> { int is = i.lastIndexOf('/'); String ip = is >= 0 ? i.substring(0, is) : ""; String il = i.toLowerCase(); return ip.equals(parentDir) - && (il.endsWith(".img") || il.endsWith(".iso") || il.endsWith(".bin")); + && (il.endsWith(".cue") || il.endsWith(".ccd")); }); - if (hasData) continue; + if (hasDescriptor) continue; } seenDirs.add(parentDir); - String flags = imgLower.endsWith(".bin") ? " -t cdrom -fs iso" : " -t cdrom"; + String flags = (imgLower.endsWith(".bin") && !imgLower.endsWith(".cue")) + ? " -t cdrom -fs iso" : " -t cdrom"; sb.append("imgmount ").append(driveLetter).append(" \"").append(img).append("\"").append(flags).append("\n"); driveLetter++; }