This commit is contained in:
@@ -3,7 +3,9 @@ package com.dostalgia;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Single source of truth for all DOSBox configuration generation.
|
||||
@@ -11,11 +13,6 @@ import java.util.*;
|
||||
@ApplicationScoped
|
||||
public class ConfigBuilder {
|
||||
|
||||
/** Priority: .cue (5) > .iso (4) > .ccd (3) > .img (2) > .bin (1) */
|
||||
private static final Map<String, Integer> CD_FORMAT_PRIORITY = Map.of(
|
||||
".cue", 5, ".iso", 4, ".ccd", 3, ".img", 2, ".bin", 1
|
||||
);
|
||||
|
||||
/**
|
||||
* Build a dosbox.conf for a game with a known executable.
|
||||
* @param relExe relative path to the executable inside the ZIP (e.g. "FALLOUT.EXE" or "FALLOUT/FALLOUT.EXE")
|
||||
|
||||
@@ -20,7 +20,7 @@ import java.util.regex.Pattern;
|
||||
public class ConfigPatcher {
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(ConfigPatcher.class.getName());
|
||||
private static final Pattern DRIVE_PATH = Pattern.compile("[A-Za-z]:(\\\\|/)[^\\s\"\\r\\n]+");
|
||||
private static final Pattern DRIVE_PATH = Pattern.compile("[A-Za-z]:([\\\\/])[^\\s\"\\r\\n]+");
|
||||
|
||||
/** Scan and fix absolute paths in all text files in the given directory. */
|
||||
public void fixAbsolutePaths(Path extractDir) throws IOException {
|
||||
|
||||
@@ -81,7 +81,7 @@ public class GameService implements GameStore {
|
||||
// Detect bundle size
|
||||
try {
|
||||
Path bundlePath = gamesDir.resolve(game.getBundleFile());
|
||||
if (bundlePath != null && Files.exists(bundlePath)) {
|
||||
if (Files.exists(bundlePath)) {
|
||||
game.setBundleSize(Files.size(bundlePath));
|
||||
}
|
||||
} catch (IOException ignored) {}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.dostalgia;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.NoSuchFileException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
|
||||
@@ -10,7 +9,7 @@ import java.util.List;
|
||||
* Decouples consumers (IgdbService, GameController) from the concrete storage implementation.
|
||||
*/
|
||||
public interface GameStore {
|
||||
Game load(String id) throws IOException, NoSuchFileException;
|
||||
Game load(String id) throws IOException;
|
||||
void save(Game game) throws IOException;
|
||||
List<Game> list() throws IOException;
|
||||
void delete(String id) throws IOException;
|
||||
|
||||
@@ -28,7 +28,7 @@ public class IgdbService {
|
||||
private static final String TWITCH_AUTH = "https://id.twitch.tv/oauth2/token";
|
||||
private static final String IGDB_API = "https://api.igdb.com/v4";
|
||||
private static final String IMG_BASE = "https://images.igdb.com/igdb/image/upload";
|
||||
private static final String COVER_SIZE = "t_cover_big"; // ~264x352, good for grid display
|
||||
private static final String COVER_SIZE = "t_cover_big";
|
||||
|
||||
private final HttpClient http = HttpClient.newHttpClient();
|
||||
private final ObjectMapper mapper = new ObjectMapper();
|
||||
|
||||
@@ -49,7 +49,6 @@ public class PlatformDetector {
|
||||
sig2 = buf[peOffset + 1];
|
||||
} else {
|
||||
try (var fis2 = Files.newInputStream(exePath)) {
|
||||
fis2.skip(peOffset);
|
||||
sig1 = (byte) fis2.read();
|
||||
sig2 = (byte) fis2.read();
|
||||
}
|
||||
|
||||
@@ -31,9 +31,6 @@ public class UploadResource {
|
||||
@Inject
|
||||
IgdbService igdb;
|
||||
|
||||
@Inject
|
||||
ConfigBuilder config;
|
||||
|
||||
@Inject
|
||||
ZipService zip;
|
||||
|
||||
@@ -202,7 +199,7 @@ public class UploadResource {
|
||||
}
|
||||
|
||||
String fname = upload.fileName().toLowerCase();
|
||||
String ext = "";
|
||||
String ext;
|
||||
if (fname.endsWith(".jpg") || fname.endsWith(".jpeg")) ext = ".jpg";
|
||||
else if (fname.endsWith(".png")) ext = ".png";
|
||||
else if (fname.endsWith(".webp")) ext = ".webp";
|
||||
|
||||
Reference in New Issue
Block a user