70
70
import java .util .Map ;
71
71
import java .util .Set ;
72
72
import java .util .TreeMap ;
73
+ import java .util .function .Predicate ;
74
+
73
75
import org .graalvm .polyglot .io .FileSystem ;
74
76
75
77
public final class VirtualFileSystem implements FileSystem {
@@ -120,8 +122,16 @@ private static final record Entry(boolean isFile, Object data) {};
120
122
* If that file or directory actually exists, it will not be accessible.
121
123
*/
122
124
private final Path mountPoint ;
125
+
126
+ /**
127
+ * The temporary directory where to extract files/directories to.
128
+ */
123
129
private final Path extractDir ;
124
- private final DirectoryStream .Filter <Path > extractFilter ;
130
+
131
+ /**
132
+ * A filter to determine if a path should be extracted (see {@link #shouldExtract(Path)}).
133
+ */
134
+ private final Predicate <Path > extractFilter ;
125
135
private static final boolean caseInsensitive = isWindows ();
126
136
127
137
public VirtualFileSystem () {
@@ -134,7 +144,7 @@ public VirtualFileSystem() {
134
144
* {@link #toAbsolutePath(Path) absolute path} is computed. This argument may be {@code null}
135
145
* causing that no extraction will happen.
136
146
*/
137
- public VirtualFileSystem (DirectoryStream . Filter <Path > extractFilter ) {
147
+ public VirtualFileSystem (Predicate <Path > extractFilter ) {
138
148
String mp = System .getenv ("GRAALPY_VFS_MOUNT_POINT" );
139
149
if (mp == null ) {
140
150
mp = isWindows () ? "X:\\ graalpy_vfs" : "/graalpy_vfs" ;
@@ -323,15 +333,10 @@ private Entry file(Path path) throws IOException {
323
333
}
324
334
325
335
/**
326
- * Determines if the given platform path should be extracted to a temp directory. This is
327
- * determined by the provided filter accepts the path.
336
+ * Uses {@link #extractFilter} to determine if the given platform path should be extracted.
328
337
*/
329
338
private boolean shouldExtract (Path path ) {
330
- try {
331
- return extractFilter != null && extractFilter .accept (path );
332
- } catch (IOException e ) {
333
- throw new IllegalStateException (e );
334
- }
339
+ return extractFilter != null && extractFilter .test (path );
335
340
}
336
341
337
342
/**
0 commit comments