File tree Expand file tree Collapse file tree 12 files changed +409
-18
lines changed
java/org/quiltmc/loader/impl
resources/META-INF/quilt-bootstrap Expand file tree Collapse file tree 12 files changed +409
-18
lines changed Original file line number Diff line number Diff line change 59
59
@ SuppressWarnings ("unchecked" ) // TODO make more specific
60
60
@ QuiltLoaderInternal (QuiltLoaderInternalType .LEGACY_EXPOSED )
61
61
public final class QuiltJoinedFileSystemProvider extends FileSystemProvider {
62
- public QuiltJoinedFileSystemProvider () {}
62
+ public QuiltJoinedFileSystemProvider () {
63
+ if (instance == null ) {
64
+ instance = this ;
65
+ }
66
+ }
63
67
64
68
public static final String SCHEME = "quilt.jfs" ;
65
69
70
+ private static QuiltJoinedFileSystemProvider instance ;
66
71
private static final Map <String , WeakReference <QuiltJoinedFileSystem >> ACTIVE_FILESYSTEMS = new HashMap <>();
67
72
68
73
static {
@@ -108,12 +113,25 @@ static synchronized void closeFileSystem(QuiltJoinedFileSystem fs) {
108
113
}
109
114
110
115
public static QuiltJoinedFileSystemProvider instance () {
116
+ QuiltJoinedFileSystemProvider found = findInstance ();
117
+ if (found != null ) {
118
+ return found ;
119
+ }
120
+ throw new IllegalStateException ("Unable to load QuiltJoinedFileSystemProvider via services!" );
121
+ }
122
+
123
+ public static QuiltJoinedFileSystemProvider findInstance () {
124
+ if (instance != null ) {
125
+ return instance ;
126
+ }
127
+
111
128
for (FileSystemProvider provider : FileSystemProvider .installedProviders ()) {
112
129
if (provider instanceof QuiltJoinedFileSystemProvider ) {
113
130
return (QuiltJoinedFileSystemProvider ) provider ;
114
131
}
115
132
}
116
- throw new IllegalStateException ("Unable to load QuiltJoinedFileSystemProvider via services!" );
133
+
134
+ return instance ;
117
135
}
118
136
119
137
@ Override
Original file line number Diff line number Diff line change 20
20
import java .net .URI ;
21
21
import java .nio .file .FileStore ;
22
22
import java .nio .file .FileSystem ;
23
- import java .nio .file .FileSystemNotFoundException ;
24
23
import java .nio .file .Path ;
25
24
import java .nio .file .spi .FileSystemProvider ;
26
25
import java .util .Map ;
30
29
31
30
@ QuiltLoaderInternal (QuiltLoaderInternalType .LEGACY_EXPOSED )
32
31
public final class QuiltMemoryFileSystemProvider extends QuiltMapFileSystemProvider <QuiltMemoryFileSystem , QuiltMemoryPath > {
33
- public QuiltMemoryFileSystemProvider () {}
32
+ public QuiltMemoryFileSystemProvider () {
33
+ if (instance == null ) {
34
+ instance = this ;
35
+ }
36
+ }
34
37
35
38
public static final String SCHEME = "quilt.mfs" ;
36
39
40
+ private static QuiltMemoryFileSystemProvider instance ;
41
+
37
42
static final String READ_ONLY_EXCEPTION = "This FileSystem is read-only" ;
38
43
static final QuiltFSP <QuiltMemoryFileSystem > PROVIDER = new QuiltFSP <>(SCHEME );
39
44
40
45
public static QuiltMemoryFileSystemProvider instance () {
46
+ QuiltMemoryFileSystemProvider found = findInstance ();
47
+ if (found != null ) {
48
+ return found ;
49
+ }
50
+ throw new IllegalStateException ("Unable to load QuiltMemoryFileSystemProvider via services!" );
51
+ }
52
+
53
+ public static QuiltMemoryFileSystemProvider findInstance () {
54
+ if (instance != null ) {
55
+ return instance ;
56
+ }
57
+
41
58
for (FileSystemProvider provider : FileSystemProvider .installedProviders ()) {
42
59
if (provider instanceof QuiltMemoryFileSystemProvider ) {
43
60
return (QuiltMemoryFileSystemProvider ) provider ;
44
61
}
45
62
}
46
- throw new IllegalStateException ("Unable to load QuiltMemoryFileSystemProvider via services!" );
63
+
64
+ return instance ;
47
65
}
48
66
49
67
@ Override
Original file line number Diff line number Diff line change 40
40
41
41
@ QuiltLoaderInternal (QuiltLoaderInternalType .NEW_INTERNAL )
42
42
public class QuiltUnifiedFileSystemProvider extends QuiltMapFileSystemProvider <QuiltUnifiedFileSystem , QuiltUnifiedPath > {
43
- public QuiltUnifiedFileSystemProvider () {}
43
+ public QuiltUnifiedFileSystemProvider () {
44
+ if (instance == null ) {
45
+ instance = this ;
46
+ }
47
+ }
44
48
45
49
public static final String SCHEME = "quilt.ufs" ;
46
50
47
51
static final String READ_ONLY_EXCEPTION = "This FileSystem is read-only" ;
48
52
static final QuiltFSP <QuiltUnifiedFileSystem > PROVIDER = new QuiltFSP <>(SCHEME );
49
53
54
+ private static QuiltUnifiedFileSystemProvider instance ;
55
+
50
56
public static QuiltUnifiedFileSystemProvider instance () {
57
+ QuiltUnifiedFileSystemProvider found = findInstance ();
58
+ if (found != null ) {
59
+ return found ;
60
+ }
61
+ throw new IllegalStateException ("Unable to load QuiltUnifiedFileSystemProvider via services!" );
62
+ }
63
+
64
+ public static QuiltUnifiedFileSystemProvider findInstance () {
65
+ if (instance != null ) {
66
+ return instance ;
67
+ }
68
+
51
69
for (FileSystemProvider provider : FileSystemProvider .installedProviders ()) {
52
70
if (provider instanceof QuiltUnifiedFileSystemProvider ) {
53
71
return (QuiltUnifiedFileSystemProvider ) provider ;
54
72
}
55
73
}
56
- throw new IllegalStateException ("Unable to load QuiltUnifiedFileSystemProvider via services!" );
74
+
75
+ return instance ;
57
76
}
58
77
59
78
@ Override
Original file line number Diff line number Diff line change 29
29
30
30
@ QuiltLoaderInternal (QuiltLoaderInternalType .NEW_INTERNAL )
31
31
public class QuiltZipFileSystemProvider extends QuiltMapFileSystemProvider <QuiltZipFileSystem , QuiltZipPath > {
32
+ public QuiltZipFileSystemProvider () {
33
+ if (instance == null ) {
34
+ instance = this ;
35
+ }
36
+ }
32
37
33
38
public static final String SCHEME = "quilt.zfs" ;
34
39
static final String READ_ONLY_EXCEPTION = "This FileSystem is read-only" ;
35
40
static final QuiltFSP <QuiltZipFileSystem > PROVIDER = new QuiltFSP <>(SCHEME );
41
+ private static QuiltZipFileSystemProvider instance ;
36
42
37
43
public static QuiltZipFileSystemProvider instance () {
44
+ QuiltZipFileSystemProvider found = findInstance ();
45
+ if (found != null ) {
46
+ return found ;
47
+ }
48
+ throw new IllegalStateException ("Unable to load QuiltZipFileSystemProvider via services!" );
49
+ }
50
+
51
+ public static QuiltZipFileSystemProvider findInstance () {
52
+ if (instance != null ) {
53
+ return instance ;
54
+ }
55
+
38
56
for (FileSystemProvider provider : FileSystemProvider .installedProviders ()) {
39
57
if (provider instanceof QuiltZipFileSystemProvider ) {
40
58
return (QuiltZipFileSystemProvider ) provider ;
41
59
}
42
60
}
43
- throw new IllegalStateException ("Unable to load QuiltZipFileSystemProvider via services!" );
61
+
62
+ return instance ;
44
63
}
45
64
46
65
@ Override
Original file line number Diff line number Diff line change 23
23
import java .net .URL ;
24
24
import java .net .URLConnection ;
25
25
import java .net .URLStreamHandler ;
26
- import java .nio .file .Files ;
27
- import java .nio .file .Path ;
28
26
29
27
import org .quiltmc .loader .impl .filesystem .QuiltJoinedFileSystem ;
30
28
import org .quiltmc .loader .impl .filesystem .QuiltJoinedFileSystemProvider ;
36
34
@ QuiltLoaderInternal (QuiltLoaderInternalType .LEGACY_EXPOSED )
37
35
public class Handler extends URLStreamHandler {
38
36
@ Override
39
- protected URLConnection openConnection (URL u ) throws IOException {
37
+ public URLConnection openConnection (URL u ) throws IOException {
40
38
QuiltJoinedPath path ;
41
39
try {
42
40
path = QuiltJoinedFileSystemProvider .instance ().getPath (u .toURI ());
@@ -58,7 +56,7 @@ public InputStream getInputStream() throws IOException {
58
56
}
59
57
60
58
@ Override
61
- protected InetAddress getHostAddress (URL u ) {
59
+ public InetAddress getHostAddress (URL u ) {
62
60
return null ;
63
61
}
64
62
}
Original file line number Diff line number Diff line change 34
34
@ QuiltLoaderInternal (QuiltLoaderInternalType .LEGACY_EXPOSED )
35
35
public class Handler extends URLStreamHandler {
36
36
@ Override
37
- protected URLConnection openConnection (URL u ) throws IOException {
37
+ public URLConnection openConnection (URL u ) throws IOException {
38
38
QuiltMemoryPath path ;
39
39
try {
40
40
path = QuiltMemoryFileSystemProvider .instance ().getPath (u .toURI ());
@@ -56,7 +56,7 @@ public InputStream getInputStream() throws IOException {
56
56
}
57
57
58
58
@ Override
59
- protected InetAddress getHostAddress (URL u ) {
59
+ public InetAddress getHostAddress (URL u ) {
60
60
return null ;
61
61
}
62
62
}
Original file line number Diff line number Diff line change 34
34
@ QuiltLoaderInternal (QuiltLoaderInternalType .NEW_INTERNAL )
35
35
public class Handler extends URLStreamHandler {
36
36
@ Override
37
- protected URLConnection openConnection (URL u ) throws IOException {
37
+ public URLConnection openConnection (URL u ) throws IOException {
38
38
QuiltUnifiedPath path ;
39
39
try {
40
40
path = QuiltUnifiedFileSystemProvider .instance ().getPath (u .toURI ());
@@ -56,7 +56,7 @@ public InputStream getInputStream() throws IOException {
56
56
}
57
57
58
58
@ Override
59
- protected InetAddress getHostAddress (URL u ) {
59
+ public InetAddress getHostAddress (URL u ) {
60
60
return null ;
61
61
}
62
62
}
Original file line number Diff line number Diff line change 34
34
@ QuiltLoaderInternal (QuiltLoaderInternalType .LEGACY_EXPOSED )
35
35
public class Handler extends URLStreamHandler {
36
36
@ Override
37
- protected URLConnection openConnection (URL u ) throws IOException {
37
+ public URLConnection openConnection (URL u ) throws IOException {
38
38
QuiltZipPath path ;
39
39
try {
40
40
path = QuiltZipFileSystemProvider .instance ().getPath (u .toURI ());
@@ -56,7 +56,7 @@ public InputStream getInputStream() throws IOException {
56
56
}
57
57
58
58
@ Override
59
- protected InetAddress getHostAddress (URL u ) {
59
+ public InetAddress getHostAddress (URL u ) {
60
60
return null ;
61
61
}
62
62
}
You can’t perform that action at this time.
0 commit comments