Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
ziqian zhang
Grasscutter
Commits
7c899ce1
Commit
7c899ce1
authored
May 20, 2022
by
xtaodada
Committed by
Melledy
May 20, 2022
Browse files
Fix dataloader not getting path correctly
parent
d1775b13
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/utils/FileUtils.java
View file @
7c899ce1
...
@@ -9,7 +9,6 @@ import java.net.URI;
...
@@ -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 {
...
@@ -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 path
Uri
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:"
+
jar
Path
);
URI
uri
=
URI
.
create
(
"jar:file:"
+
pathUri
.
getRaw
Path
()
);
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
)
...
@@ -105,7 +103,7 @@ public final class FileUtils {
...
@@ -105,7 +103,7 @@ public final class FileUtils {
result
=
Arrays
.
stream
(
f
.
listFiles
()).
map
(
File:
:
toPath
).
toList
();
result
=
Arrays
.
stream
(
f
.
listFiles
()).
map
(
File:
:
toPath
).
toList
();
}
}
return
result
;
return
result
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment