Skip to main content

File System

File System Intro​

See File System Overview for details.

File System Management​

1. Inject file system path mapping rules​

Use injectFileSystemRule to inject a mapping between a protocol name and a file path.

API​

void injectFileSystemRule(String protocol, String path)
void injectFileSystemRule(int type, String protocol, String path)

Parameters​

ParamTypeRequiredDescription
typeintNoInjection type. Options: FS_DEFAULT, FS_LOCAL_TEMPORARY, FS_LOCAL_CACHE, FS_LOCAL_USER
protocolStringYesProtocol name
pathStringYesFile path

Example​

// Inject file path mappings; can be called multiple times; cleared when the game exits
// injectFileSystemRule(String protocol, String path);
// injectFileSystemRule(TJConstants.FS_DEFAULT, String protocol, String path);
hostHandle.injectFileSystemRule("protocol name", "path");
hostHandle.injectFileSystemRule(TJConstants.FS_DEFAULT, "default protocol", "file path");
// Override host code package paths. Except for FS_DEFAULT, repeated calls overwrite previous values.
// injectFileSystemRule(int type, String protocol, String path) | FS_LOCAL_TEMPORARY | FS_LOCAL_CACHE | FS_LOCAL_USER
// Local temp files: created on the fly, can be reclaimed anytime. No size limit.
hostHandle.injectFileSystemRule(TJConstants.FS_LOCAL_TEMPORARY, "temp protocol", "local temp path");
// Local cached files: created by caching a local temp file via API; directory and filename aren’t customizable.
// gameHandle.injectFileSystemRule(TJConstants.FS_LOCAL_CACHE, protocol: "cache protocol", path: "local cache path");
// Local user files: created by caching a temp file; directory and filename are customizable (same as env.USER_DATA_PATH).
hostHandle.injectFileSystemRule(TJConstants.FS_LOCAL_USER, "user path protocol", "local user path");

2. Update file system path mapping rules​

Call after injectFileSystemRule during runtime to notify the host to refresh mapping rules.
Note: updating mapping rules can interrupt in-flight file operations.

API​

void updateFileSystemRule()

3. Get host USER_DATA_PATH​

Retrieve the host USER_DATA_PATH storage path.

API​

String getUserDataPath()