File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed
src/main/java/net/minecraftforge/fart Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,27 @@ public static Builder builder() {
4949 return new ClassProviderBuilderImpl ();
5050 }
5151
52+ /**
53+ * Creates a class provider which reads class data from the provided library paths.
54+ * All queried class infos will be cached for subsequent queries.
55+ * <p>
56+ * The default supported library paths are ZIP files and directories.
57+ * Each path will be walked for all class files and stored in order.
58+ * Like a class path, entries added earlier take precedence over later entries with the same name.
59+ *
60+ * @param paths the paths to read from
61+ * @see #builder()
62+ */
63+ static ClassProvider fromPaths (Path ... paths ) {
64+ Builder builder = builder ().shouldCacheAll (true );
65+
66+ for (Path path : paths ) {
67+ builder .addLibrary (path );
68+ }
69+
70+ return builder .build ();
71+ }
72+
5273 /**
5374 * Creates a class provider which reads class data from the default classloader that loaded this class.
5475 */
Original file line number Diff line number Diff line change @@ -48,10 +48,13 @@ public ClassProvider.Builder addLibrary(Path path) {
4848 Path libraryDir ;
4949 if (Files .isDirectory (path )) {
5050 libraryDir = path ;
51- } else {
51+ } else if ( Files . isRegularFile ( path )) {
5252 FileSystem zipFs = FileSystems .newFileSystem (path , (ClassLoader ) null );
5353 this .fileSystems .add (zipFs );
5454 libraryDir = zipFs .getPath ("/" );
55+ } else {
56+ // We can't load it (it doesn't exist)
57+ return this ;
5558 }
5659
5760 try (Stream <Path > walker = Files .walk (libraryDir )) {
You can’t perform that action at this time.
0 commit comments