Class InternalResource.Env
java.lang.Object
com.oracle.truffle.api.InternalResource.Env
- Enclosing interface:
InternalResource
Access to common utilities for unpacking resource files.
- Since:
- 23.1
-
Method Summary
Modifier and TypeMethodDescriptionReturns the current processor architecture.getOS()Returns the current operating system.booleanReturnstrueif the engine causing the resource unpacking is being pre-initialized.booleanReturnstrueif resource unpacking happens during the native image build.readResourceLines(Path location) Reads a resource from the module, which owns theInternalResourceimplementation class.voidunpackResourceFiles(Path source, Path target, Path relativizeTo) Extracts files from the module, which owns theInternalResourceimplementation class, listed in thesourcefile list and places them into thetargetfolder.voidExtracts files from the module, which owns theInternalResourceimplementation class, listed in thesourcefile list and places them into thetargetfolder.
-
Method Details
-
inContextPreinitialization
public boolean inContextPreinitialization()Returnstrueif the engine causing the resource unpacking is being pre-initialized.- Since:
- 23.1
-
inNativeImageBuild
public boolean inNativeImageBuild()Returnstrueif resource unpacking happens during the native image build.- Since:
- 23.1
-
getCPUArchitecture
Returns the current processor architecture. The value can be used to resolve an architecture specific files during resource unpacking.- Since:
- 23.1
-
getOS
Returns the current operating system. The value can be used to resolve an OS specific files during resource unpacking.- Since:
- 23.1
-
readResourceLines
Reads a resource from the module, which owns theInternalResourceimplementation class. If the resource is encapsulated in the module, seeModule.getResourceAsStream(String), the module needs to open thelocationenclosing package to theorg.graalvm.trufflemodule. It is recommended to use non-encapsulated resource paths.- Parameters:
location- relative path that identifies the resource in the module. The relative path gets resolved into an absolute path using the archive root.- Returns:
- the lines from the resource as a
List - Throws:
IOException- in case of IO error- Since:
- 23.1
-
unpackResourceFiles
public void unpackResourceFiles(Path source, Path target, Path relativizeTo, Predicate<Path> filter) throws IOException Extracts files from the module, which owns theInternalResourceimplementation class, listed in thesourcefile list and places them into thetargetfolder. If resources are encapsulated within the module, seeModule.getResourceAsStream(String), the module needs to open the enclosing package of the resources to theorg.graalvm.trufflemodule. It is recommended to use non-encapsulated resource paths.The file list is a
Java propertiesfile where resource files serve as keys, and the corresponding values consist of serialized attributes separated by','. Currently, only the POSIX file permissions attribute is supported. The format of this attribute follows the same convention used by thePosixFilePermissions.fromString(String).Example of a file list content:
META-INF/resources/darwin/amd64/bin/libtrufflenfi.dylib = rwxr-xr-x META-INF/resources/common/include/trufflenfi.h = rw-r--r--
- Parameters:
source- the relative path that identifies the file list resource in the module. The relative path gets resolved into an absolute path using the archive root.target- the folder to extract resources torelativizeTo- the path used to relativize the file list entries in thetargetfolder. In other words, the file list entries are resolved using thetargetdirectory after removing therelativizeTopath.filter- resource path filter. Only resources at resource paths for which the filter predicate returnstrueare unpacked.- Throws:
IllegalArgumentException- ifrelativizeTois an absolute path or file list contains an absolute pathIOException- in case of IO error- Since:
- 24.2
-
unpackResourceFiles
Extracts files from the module, which owns theInternalResourceimplementation class, listed in thesourcefile list and places them into thetargetfolder. Same asunpackResourceFiles(Path, Path, Path, Predicate)withfilter = p -> true.- Throws:
IOException- Since:
- 23.1
- See Also:
-