Package com.oracle.truffle.api
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.boolean
Returnstrue
if the engine causing the resource unpacking is being pre-initialized.boolean
Returnstrue
if resource unpacking happens during the native image build.readResourceLines
(Path location) Reads a resource from the module, which owns theInternalResource
implementation class.void
unpackResourceFiles
(Path source, Path target, Path relativizeTo) Extracts files from the module, which owns theInternalResource
implementation class, listed in thesource
file list and places them into thetarget
folder.void
Extracts files from the module, which owns theInternalResource
implementation class, listed in thesource
file list and places them into thetarget
folder.
-
Method Details
-
inContextPreinitialization
public boolean inContextPreinitialization()Returnstrue
if the engine causing the resource unpacking is being pre-initialized.- Since:
- 23.1
-
inNativeImageBuild
public boolean inNativeImageBuild()Returnstrue
if 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 theInternalResource
implementation class. If the resource is encapsulated in the module, seeModule.getResourceAsStream(String)
, the module needs to open thelocation
enclosing package to theorg.graalvm.truffle
module. 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 theInternalResource
implementation class, listed in thesource
file list and places them into thetarget
folder. If resources are encapsulated within the module, seeModule.getResourceAsStream(String)
, the module needs to open the enclosing package of the resources to theorg.graalvm.truffle
module. It is recommended to use non-encapsulated resource paths.The file list is a
Java properties
file 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 thetarget
folder. In other words, the file list entries are resolved using thetarget
directory after removing therelativizeTo
path.filter
- resource path filter. Only resources at resource paths for which the filter predicate returnstrue
are unpacked.- Throws:
IllegalArgumentException
- ifrelativizeTo
is 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 theInternalResource
implementation class, listed in thesource
file list and places them into thetarget
folder. Same asunpackResourceFiles(Path, Path, Path, Predicate)
withfilter = p -> true
.- Throws:
IOException
- Since:
- 23.1
- See Also:
-