fix: prefer descriptor formats (.cue/.ccd) over raw data (.img/.bin) for DOSBox CD mounting
Build & Deploy / build-and-deploy (push) Successful in 45s
Build & Deploy / build-and-deploy (push) Successful in 45s
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.
This commit is contained in:
@@ -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<String> 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<String> 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++;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user