Skip to content

Commit ff167db

Browse files
authored
stage2/lw: Fix absolute path detection on Windows
GitHub: #32
1 parent 14bc1a6 commit ff167db

File tree

1 file changed

+9
-2
lines changed
  • stage2/launchwrapper/src/main/java/gg/essential/loader/stage2

1 file changed

+9
-2
lines changed

stage2/launchwrapper/src/main/java/gg/essential/loader/stage2/Loader.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import java.nio.file.FileSystem;
2525
import java.nio.file.FileSystems;
2626
import java.nio.file.Files;
27+
import java.nio.file.InvalidPathException;
2728
import java.nio.file.Path;
2829
import java.nio.file.Paths;
2930
import java.util.ArrayList;
@@ -369,9 +370,15 @@ private void loadDependency(JarInfo outerJar, JsonObject spec, Map<String, JarIn
369370
if (spec.has("file")) {
370371
String file = spec.getAsJsonPrimitive("file").getAsString();
371372
Path path;
372-
if (file.startsWith("/")) {
373+
try {
373374
path = FileSystems.getDefault().getPath(file);
374-
} else {
375+
if (!path.isAbsolute()) {
376+
path = null;
377+
}
378+
} catch (InvalidPathException e) {
379+
path = null;
380+
}
381+
if (path == null) {
375382
try (FileSystem fileSystem = FileSystems.newFileSystem(outerJar.path, (ClassLoader) null)) {
376383
Path innerJar = fileSystem.getPath(file);
377384
String name = innerJar.getFileName().toString();

0 commit comments

Comments
 (0)