Browse Source

#185 : fix missing slash for jar file on Windows while creating new file system (#186)

pull/191/head
Julieng50 7 years ago committed by Decebal Suiu
parent
commit
f426f98db3
  1. 7
      pf4j/src/main/java/org/pf4j/util/FileUtils.java

7
pf4j/src/main/java/org/pf4j/util/FileUtils.java

@ -43,6 +43,7 @@ import java.util.List;
*/ */
public class FileUtils { public class FileUtils {
private static final String SLASH = "/";
private static final Logger log = LoggerFactory.getLogger(FileUtils.class); private static final Logger log = LoggerFactory.getLogger(FileUtils.class);
public static List<String> readLines(Path path, boolean ignoreComments) throws IOException { public static List<String> readLines(Path path, boolean ignoreComments) throws IOException {
@ -216,7 +217,11 @@ public class FileUtils {
public static Path getPath(Path path, String first, String... more) throws IOException { public static Path getPath(Path path, String first, String... more) throws IOException {
URI uri = path.toUri(); URI uri = path.toUri();
if (isJarFile(path)) { if (isJarFile(path)) {
uri = URI.create("jar:file:" + path.toString().replace("\\", "/")); String pathString = path.toString().replace("\\", SLASH);
if(!pathString.startsWith(SLASH)){
pathString = SLASH + pathString;
}
uri = URI.create("jar:file:" + pathString);
} }
return getPath(uri, first, more); return getPath(uri, first, more);

Loading…
Cancel
Save