Skip to content

Commit 8cfbb20

Browse files
author
Aleksandar Gradinac
committed
Fix resource inclusion on Windows
1 parent 4f4d276 commit 8cfbb20

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ResourcesFeature.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import java.net.URL;
3434
import java.net.URLClassLoader;
3535
import java.nio.file.FileSystem;
36+
import java.nio.file.FileSystems;
3637
import java.util.ArrayList;
3738
import java.util.Arrays;
3839
import java.util.Collections;
@@ -252,13 +253,16 @@ private static void scanDirectory(DebugContext debugContext, File root, Pattern[
252253
Map<String, List<String>> matchedDirectoryResources = new HashMap<>();
253254
Set<String> allEntries = new HashSet<>();
254255
ArrayList<File> queue = new ArrayList<>();
256+
String separator = FileSystems.getDefault().getSeparator();
255257

256258
queue.add(root);
257259
while (!queue.isEmpty()) {
258260
File file = queue.remove(0);
259261
String relativeFilePath = "";
260262
if (file != root) {
261263
relativeFilePath = file.getAbsolutePath().substring(root.getAbsolutePath().length() + 1);
264+
/* Java resources always use / as the path separator, as do our resource inclusion patterns. */
265+
relativeFilePath = relativeFilePath.replace(separator, "/");
262266
}
263267
if (file.isDirectory()) {
264268
if (!relativeFilePath.isEmpty()) {

0 commit comments

Comments
 (0)