mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-27 12:05:52 +00:00
Fix dataloader not getting path correctly
This commit is contained in:
parent
d59e14e383
commit
0766ec3805
@ -9,7 +9,6 @@ import java.net.URI;
|
|||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.nio.file.*;
|
import java.nio.file.*;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -77,19 +76,18 @@ public final class FileUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// From https://mkyong.com/java/java-read-a-file-from-resources-folder/
|
// From https://mkyong.com/java/java-read-a-file-from-resources-folder/
|
||||||
public static List<Path> getPathsFromResource(String folder) throws URISyntaxException, IOException {
|
public static List<Path> getPathsFromResource(String folder) throws URISyntaxException {
|
||||||
List<Path> result = null;
|
List<Path> result = null;
|
||||||
|
|
||||||
// Get path of the current running JAR
|
// Get pathUri of the current running JAR
|
||||||
String jarPath = Grasscutter.class.getProtectionDomain()
|
URI pathUri = Grasscutter.class.getProtectionDomain()
|
||||||
.getCodeSource()
|
.getCodeSource()
|
||||||
.getLocation()
|
.getLocation()
|
||||||
.toURI()
|
.toURI();
|
||||||
.getPath();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// file walks JAR
|
// file walks JAR
|
||||||
URI uri = URI.create("jar:file:" + jarPath);
|
URI uri = URI.create("jar:file:" + pathUri.getRawPath());
|
||||||
try (FileSystem fs = FileSystems.newFileSystem(uri, Collections.emptyMap())) {
|
try (FileSystem fs = FileSystems.newFileSystem(uri, Collections.emptyMap())) {
|
||||||
result = Files.walk(fs.getPath(folder))
|
result = Files.walk(fs.getPath(folder))
|
||||||
.filter(Files::isRegularFile)
|
.filter(Files::isRegularFile)
|
||||||
|
Loading…
Reference in New Issue
Block a user