Fix js-dos ZIP extraction: add explicit directory entries to bundles
Build & Deploy / build-and-deploy (push) Successful in 46s
Build & Deploy / build-and-deploy (push) Successful in 46s
js-dos uses Emscripten's virtual filesystem which requires explicit ZIP directory entries (names ending with '/') to create directories. Java's ZipOutputStream only writes file entries, so subdirectories like NAS50TH/TRACKS/WILKES/ were never created — causing Emscripten 'No such file or directory' errors for any path inside them. - createBundle: before writing each file entry, add its parent directory as an explicit ZIP entry if not already added - Affects all games with subdirectory structures (NASCAR Racing 2, Gus Goes to Cyberopolis, etc.) - Use a HashSet to track already-added directories (no duplicates)
This commit is contained in:
@@ -289,9 +289,20 @@ public class UploadResource {
|
|||||||
|
|
||||||
// ZIP it up directly from extractDir (no temp copy)
|
// ZIP it up directly from extractDir (no temp copy)
|
||||||
try (var zos = new java.util.zip.ZipOutputStream(Files.newOutputStream(bundlePath))) {
|
try (var zos = new java.util.zip.ZipOutputStream(Files.newOutputStream(bundlePath))) {
|
||||||
|
var addedDirs = new java.util.HashSet<String>();
|
||||||
Files.walk(extractDir).filter(Files::isRegularFile).forEach(f -> {
|
Files.walk(extractDir).filter(Files::isRegularFile).forEach(f -> {
|
||||||
try {
|
try {
|
||||||
String entryName = extractDir.relativize(f).toString().replace('\\', '/');
|
String entryName = extractDir.relativize(f).toString().replace('\\', '/');
|
||||||
|
// Ensure all parent directories have explicit entries
|
||||||
|
// (js-dos Emscripten FS requires explicit directory entries)
|
||||||
|
int idx = entryName.lastIndexOf('/');
|
||||||
|
if (idx >= 0) {
|
||||||
|
String parent = entryName.substring(0, idx + 1);
|
||||||
|
if (addedDirs.add(parent)) {
|
||||||
|
zos.putNextEntry(new java.util.zip.ZipEntry(parent));
|
||||||
|
zos.closeEntry();
|
||||||
|
}
|
||||||
|
}
|
||||||
zos.putNextEntry(new java.util.zip.ZipEntry(entryName));
|
zos.putNextEntry(new java.util.zip.ZipEntry(entryName));
|
||||||
Files.copy(f, zos);
|
Files.copy(f, zos);
|
||||||
zos.closeEntry();
|
zos.closeEntry();
|
||||||
|
|||||||
Reference in New Issue
Block a user