From 596b897df61c05bef8fe0881516648f48c7edbb8 Mon Sep 17 00:00:00 2001 From: David Alvarez Date: Wed, 27 May 2026 10:41:45 +0200 Subject: [PATCH] fix: use backslash path separator for DOS paths extractDir.relativize() returns paths with native Linux forward slashes. DOS requires backslashes. Changed .replace('\', '/') to .replace('/', '\') and updated buildDosboxConf split logic to also check for backslash separator. --- src/main/java/com/dostalgia/UploadResource.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/dostalgia/UploadResource.java b/src/main/java/com/dostalgia/UploadResource.java index b489729..798f858 100644 --- a/src/main/java/com/dostalgia/UploadResource.java +++ b/src/main/java/com/dostalgia/UploadResource.java @@ -88,7 +88,7 @@ public class UploadResource { // Write dosbox.conf (full config, not just autoexec) Path jsdos = gameDir.resolve(".jsdos"); Files.createDirectories(jsdos); - String relExe = extractDir.relativize(Path.of(mainExe)).toString().replace('\\', '/'); + String relExe = extractDir.relativize(Path.of(mainExe)).toString().replace('/', '\\'); String conf = buildDosboxConf(relExe); Files.writeString(jsdos.resolve("dosbox.conf"), conf); Files.write(jsdos.resolve("jsdos.json"), buildJsdosJson(relExe)); @@ -216,7 +216,7 @@ public class UploadResource { // Create .jsdos config (full config, not just autoexec) Path jsdos = tmpBundle.resolve(".jsdos"); Files.createDirectories(jsdos); - String relExe = extractDir.relativize(Path.of(mainExe)).toString().replace('\\', '/'); + String relExe = extractDir.relativize(Path.of(mainExe)).toString().replace('/', '\\'); String conf = buildDosboxConf(relExe); Files.writeString(jsdos.resolve("dosbox.conf"), conf); Files.write(jsdos.resolve("jsdos.json"), buildJsdosJson(relExe)); @@ -274,7 +274,7 @@ public class UploadResource { // Split into directory and executable components for subdirectory support String dir = ""; String exe = relExe; - int idx = relExe.lastIndexOf('/'); + int idx = Math.max(relExe.lastIndexOf('/'), relExe.lastIndexOf('\\')); if (idx >= 0) { dir = relExe.substring(0, idx); exe = relExe.substring(idx + 1);