Skip to content

Commit

Permalink
[GR-14598] Language environment and Truffle FileSystem does not expos…
Browse files Browse the repository at this point in the history
…e the path separator.

PullRequest: graal/3646
  • Loading branch information
tzezula committed May 22, 2019
2 parents ac702cd + ec4a43e commit 52b6eba
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 3 deletions.
3 changes: 2 additions & 1 deletion sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ This changelog summarizes major changes between GraalVM SDK versions. The main f

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

## Version 19.0.0
## Version 19.0.0
* `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.

## Version 1.0.0 RC16
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public interface LanguageProvider {
*
* @param context the context for a guest language code literal evaluation
* @return the {@link Snippet} representing the identity function
* @since 1.0
* @since 20.0.0 beta 1
*/
default Snippet createIdentityFunctionSnippet(Context context) {
Value value = createIdentityFunction(context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ static ResultVerifier getDefaultResultVerifier() {
* {@link ResultVerifier} tests that the identity function does not change the parameter type.
*
* @return the default {@link ResultVerifier} for {@code IdentityFunctionTest}.
* @since 1.0
* @since 20.0.0 beta 1
*/
static ResultVerifier getIdentityFunctionDefaultResultVerifier() {
return IdentityFunctionResultVerifier.INSTANCE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
*/
package org.graalvm.polyglot.io;

import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.nio.channels.SeekableByteChannel;
Expand Down Expand Up @@ -349,6 +350,17 @@ default String getSeparator() {
return parsePath("").getFileSystem().getSeparator();
}

/**
* Returns the path separator used to separate filenames in a path list. On UNIX the path
* separator is {@code ':'}. On Windows it's {@code ';'}.
*
* @return the path separator
* @since 20.0.0 beta 1
*/
default String getPathSeparator() {
return File.pathSeparator;
}

/**
* Returns a MIME type for given path. An optional operation for {@link FileSystem filesystem}
* implementations which can provide MIME types in an efficient way.
Expand Down
1 change: 1 addition & 0 deletions truffle/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ This changelog summarizes major changes between Truffle versions relevant to lan
* Removed deprecated and misspelled method `TruffleStackTrace#getStacktrace`.
* Removed deprecated methods`TruffleStackTraceElement#getStackTrace` and `TruffleStackTraceElement#fillIn` (use methods of `TruffleStackTrace` instead).
* `SlowPathException#fillInStackTrace` is now `final`.
* 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.

## Version 19.0.0
* Renamed version 1.0.0 to 19.0.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1320,6 +1320,15 @@ public void testGetFileNameSeparator() {
ctx.eval(LANGUAGE_ID, "");
}

@Test
public void testGetPathSeparator() {
final Context ctx = cfg.getContext();
languageAction = (Env env) -> {
Assert.assertEquals(cfg.fileSystem.getSeparator(), env.getFileNameSeparator());
};
ctx.eval(LANGUAGE_ID, "");
}

@Test
public void testGetAttribute() {
Context ctx = cfg.getContext();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2084,6 +2084,23 @@ public String getFileNameSeparator() {
}
}

/**
* Returns the path separator used to separate filenames in a path list. On UNIX the path
* separator is {@code ':'}. On Windows it's {@code ';'}.
*
* @return the path separator
* @since 20.0.0 beta 1
*/
@TruffleBoundary
public String getPathSeparator() {
checkDisposed();
try {
return fileSystemContext.fileSystem.getPathSeparator();
} catch (Throwable t) {
throw TruffleFile.wrapHostException(t, fileSystemContext.fileSystem);
}
}

/**
* Registers additional services provided by the language. The registered services are made
* available to users via
Expand Down

0 comments on commit 52b6eba

Please sign in to comment.