@@ -134,8 +134,9 @@ public static final class Builder {
134134 return s .endsWith (".so" ) || s .endsWith (".dylib" ) || s .endsWith (".pyd" ) || s .endsWith (".dll" ) || s .endsWith (".ttf" );
135135 };
136136
137- private String windowsMountPoint = "X:\\ graalpy_vfs" ;
138- private String unixMountPoint = "/graalpy_vfs" ;
137+ private static final String DEFAULT_WINDOWS_MOUNT_POINT = "X:\\ graalpy_vfs" ;
138+ private String DEFAULT_UNIX_MOUNT_POINT = "/graalpy_vfs" ;
139+ private Path mountPoint ;
139140 private Predicate <Path > extractFilter = DEFAULT_EXTRACT_FILTER ;
140141 private HostIO allowHostIO = HostIO .READ_WRITE ;
141142 private boolean caseInsensitive = isWindows ();
@@ -171,7 +172,9 @@ public Builder allowHostIO(HostIO b) {
171172 * will not be accessible.
172173 */
173174 public Builder windowsMountPoint (String s ) {
174- windowsMountPoint = s ;
175+ if (isWindows ()) {
176+ mountPoint = getMountPointAsPath (s );
177+ }
175178 return this ;
176179 }
177180
@@ -184,7 +187,9 @@ public Builder windowsMountPoint(String s) {
184187 * will not be accessible.
185188 */
186189 public Builder unixMountPoint (String s ) {
187- unixMountPoint = s ;
190+ if (!isWindows ()) {
191+ mountPoint = getMountPointAsPath (s );
192+ }
188193 return this ;
189194 }
190195
@@ -219,10 +224,21 @@ public Builder extractFilter(Predicate<Path> filter) {
219224 }
220225
221226 public VirtualFileSystem build () {
222- return new VirtualFileSystem (extractFilter , windowsMountPoint , unixMountPoint , allowHostIO , resourceLoadingClass , caseInsensitive );
227+ if (mountPoint == null ) {
228+ mountPoint = isWindows () ? Path .of (DEFAULT_WINDOWS_MOUNT_POINT ) : Path .of (DEFAULT_UNIX_MOUNT_POINT );
229+ }
230+ return new VirtualFileSystem (extractFilter , mountPoint , allowHostIO , resourceLoadingClass , caseInsensitive );
223231 }
224232 }
225233
234+ private static Path getMountPointAsPath (String mp ) {
235+ Path mountPoint = Path .of (mp );
236+ if (mp .endsWith (PLATFORM_SEPARATOR ) || !mountPoint .isAbsolute ()) {
237+ throw new IllegalArgumentException (String .format ("Virtual filesystem mount point must be set to an absolute path without a trailing separator: '%s'" , mp ));
238+ }
239+ return mountPoint ;
240+ }
241+
226242 public static Builder newBuilder () {
227243 return new Builder ();
228244 }
@@ -353,8 +369,7 @@ private void removeExtractDir() {
353369 * causing that no extraction will happen.
354370 */
355371 VirtualFileSystem (Predicate <Path > extractFilter ,
356- String windowsMountPoint ,
357- String unixMountPoint ,
372+ Path mountPoint ,
358373 HostIO allowHostIO ,
359374 Class <?> resourceLoadingClass ,
360375 boolean caseInsensitive ) {
@@ -365,15 +380,9 @@ private void removeExtractDir() {
365380 }
366381
367382 this .caseInsensitive = caseInsensitive ;
368- String mp = System .getenv ("GRAALPY_VFS_MOUNT_POINT" );
369- if (mp == null ) {
370- mp = isWindows () ? windowsMountPoint : unixMountPoint ;
371- }
372- this .mountPoint = Path .of (mp );
373- this .mountPointLowerCase = mp .toLowerCase (Locale .ROOT );
374- if (mp .endsWith (PLATFORM_SEPARATOR ) || !mountPoint .isAbsolute ()) {
375- throw new IllegalArgumentException ("GRAALPY_VFS_MOUNT_POINT must be set to an absolute path without a trailing separator" );
376- }
383+ this .mountPoint = mountPoint ;
384+
385+ this .mountPointLowerCase = mountPoint .toString ().toLowerCase (Locale .ROOT );
377386
378387 fine ("VirtualFilesystem %s, allowHostIO: %s, resourceLoadingClass: %s, caseInsensitive: %s, extractOnStartup: %s%s" ,
379388 mountPoint , allowHostIO .toString (), this .resourceLoadingClass .getName (), caseInsensitive , extractOnStartup , extractFilter != null ? "" : ", extractFilter: null" );
0 commit comments