Skip to content

Commit 2650039

Browse files
committed
make VFS.resourcePathToPlatformPath public and deprecated to avoid compilations errors when upgrading graalpy 24.0.0 -> 24.2.0
1 parent b817122 commit 2650039

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

graalpython/org.graalvm.python.embedding/src/org/graalvm/python/embedding/utils/VirtualFileSystem.java

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -404,14 +404,27 @@ String vfsVenvPath() {
404404
return resourcePathToPlatformPath(VENV_PREFIX);
405405
}
406406

407-
private String resourcePathToPlatformPath(String inputPath) {
408-
assert inputPath.length() > VFS_ROOT.length() && inputPath.startsWith(VFS_ROOT) : "inputPath expected to start with '" + VFS_ROOT + "' but was '" + inputPath + "'";
409-
var path = inputPath.substring(VFS_ROOT.length() + 1);
407+
/**
408+
* Converts the given path starting with the internal resource root to the path as seen by
409+
* Python IO. For example if no other mount point was set then the path
410+
* "/org.graalvm.python.vfs/src/hello.py" will be converted to the default mount point
411+
* "/graalpy_vfs/src/hello.py" .
412+
*
413+
* @deprecated use {@link #getMountPoint()} instead
414+
*/
415+
@Deprecated
416+
public String resourcePathToPlatformPath(String resourcePath) {
417+
if (!(resourcePath.length() > VFS_ROOT.length() && resourcePath.startsWith(VFS_ROOT))) {
418+
String msg = "Resource path is expected to start with '" + VFS_ROOT + "' but was '" + resourcePath + "'.\n" +
419+
"Please also ensure that your virtual file system resources root directory is '" + VFS_ROOT + "'";
420+
throw new IllegalArgumentException(msg);
421+
}
422+
var path = resourcePath.substring(VFS_ROOT.length() + 1);
410423
if (!PLATFORM_SEPARATOR.equals(RESOURCE_SEPARATOR)) {
411424
path = path.replace(RESOURCE_SEPARATOR, PLATFORM_SEPARATOR);
412425
}
413426
String absolute = mountPoint.resolve(path).toString();
414-
if (inputPath.endsWith(RESOURCE_SEPARATOR) && !absolute.endsWith(PLATFORM_SEPARATOR)) {
427+
if (resourcePath.endsWith(RESOURCE_SEPARATOR) && !absolute.endsWith(PLATFORM_SEPARATOR)) {
415428
absolute += PLATFORM_SEPARATOR;
416429
}
417430
return absolute;

0 commit comments

Comments
 (0)