Skip to content

Commit 52b6eba

Browse files
committed
[GR-14598] Language environment and Truffle FileSystem does not expose the path separator.
PullRequest: graal/3646
2 parents ac702cd + ec4a43e commit 52b6eba

File tree

7 files changed

+43
-3
lines changed

7 files changed

+43
-3
lines changed

sdk/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ This changelog summarizes major changes between GraalVM SDK versions. The main f
44

55
## Version 20.0.0 Beta 1
66
* Removed deprecated `OptionCategory.DEBUG` (use `OptionCategory.INTERNAL` instead).
7+
* The path separator can now be configured by [FileSystem](http://www.graalvm.org/sdk/javadoc/org/graalvm/polyglot/io/FileSystem.html#getPathSeparator--).
78

8-
## Version 19.0.0
9+
## Version 19.0.0
910
* `Value.as(Interface.class)` now requires interface classes to be annotated with `HostAccess.Implementable` in `EXPLICIT` host access mode. Added new APIs to configure implementable behavior in HostAccess.
1011

1112
## Version 1.0.0 RC16

sdk/src/org.graalvm.polyglot.tck/src/org/graalvm/polyglot/tck/LanguageProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public interface LanguageProvider {
9696
*
9797
* @param context the context for a guest language code literal evaluation
9898
* @return the {@link Snippet} representing the identity function
99-
* @since 1.0
99+
* @since 20.0.0 beta 1
100100
*/
101101
default Snippet createIdentityFunctionSnippet(Context context) {
102102
Value value = createIdentityFunction(context);

sdk/src/org.graalvm.polyglot.tck/src/org/graalvm/polyglot/tck/ResultVerifier.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ static ResultVerifier getDefaultResultVerifier() {
179179
* {@link ResultVerifier} tests that the identity function does not change the parameter type.
180180
*
181181
* @return the default {@link ResultVerifier} for {@code IdentityFunctionTest}.
182-
* @since 1.0
182+
* @since 20.0.0 beta 1
183183
*/
184184
static ResultVerifier getIdentityFunctionDefaultResultVerifier() {
185185
return IdentityFunctionResultVerifier.INSTANCE;

sdk/src/org.graalvm.polyglot/src/org/graalvm/polyglot/io/FileSystem.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
*/
4141
package org.graalvm.polyglot.io;
4242

43+
import java.io.File;
4344
import java.io.IOException;
4445
import java.net.URI;
4546
import java.nio.channels.SeekableByteChannel;
@@ -349,6 +350,17 @@ default String getSeparator() {
349350
return parsePath("").getFileSystem().getSeparator();
350351
}
351352

353+
/**
354+
* Returns the path separator used to separate filenames in a path list. On UNIX the path
355+
* separator is {@code ':'}. On Windows it's {@code ';'}.
356+
*
357+
* @return the path separator
358+
* @since 20.0.0 beta 1
359+
*/
360+
default String getPathSeparator() {
361+
return File.pathSeparator;
362+
}
363+
352364
/**
353365
* Returns a MIME type for given path. An optional operation for {@link FileSystem filesystem}
354366
* implementations which can provide MIME types in an efficient way.

truffle/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ This changelog summarizes major changes between Truffle versions relevant to lan
77
* Removed deprecated and misspelled method `TruffleStackTrace#getStacktrace`.
88
* Removed deprecated methods`TruffleStackTraceElement#getStackTrace` and `TruffleStackTraceElement#fillIn` (use methods of `TruffleStackTrace` instead).
99
* `SlowPathException#fillInStackTrace` is now `final`.
10+
* Added an ability to read a [path separator](https://www.graalvm.org/truffle/javadoc/com/oracle/truffle/api/TruffleLanguage.Env.html#getPathSeparator--) used to separate filenames in a path list.
1011

1112
## Version 19.0.0
1213
* Renamed version 1.0.0 to 19.0.0

truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/polyglot/VirtualizedFileSystemTest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,6 +1320,15 @@ public void testGetFileNameSeparator() {
13201320
ctx.eval(LANGUAGE_ID, "");
13211321
}
13221322

1323+
@Test
1324+
public void testGetPathSeparator() {
1325+
final Context ctx = cfg.getContext();
1326+
languageAction = (Env env) -> {
1327+
Assert.assertEquals(cfg.fileSystem.getSeparator(), env.getFileNameSeparator());
1328+
};
1329+
ctx.eval(LANGUAGE_ID, "");
1330+
}
1331+
13231332
@Test
13241333
public void testGetAttribute() {
13251334
Context ctx = cfg.getContext();

truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/TruffleLanguage.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2084,6 +2084,23 @@ public String getFileNameSeparator() {
20842084
}
20852085
}
20862086

2087+
/**
2088+
* Returns the path separator used to separate filenames in a path list. On UNIX the path
2089+
* separator is {@code ':'}. On Windows it's {@code ';'}.
2090+
*
2091+
* @return the path separator
2092+
* @since 20.0.0 beta 1
2093+
*/
2094+
@TruffleBoundary
2095+
public String getPathSeparator() {
2096+
checkDisposed();
2097+
try {
2098+
return fileSystemContext.fileSystem.getPathSeparator();
2099+
} catch (Throwable t) {
2100+
throw TruffleFile.wrapHostException(t, fileSystemContext.fileSystem);
2101+
}
2102+
}
2103+
20872104
/**
20882105
* Registers additional services provided by the language. The registered services are made
20892106
* available to users via

0 commit comments

Comments
 (0)