Skip to main content

Module app_paths

Module app_paths 

Source
Expand description

Process-global app location: the directory an app was loaded from, and the per-user directory it keeps saved data in.

A script function that names a file runs outside the world, so it cannot look the app up through a &World. It reads this cache instead, the way crate::i18n and crate::window_state carry their own process-global seams. The runtime publishes both values with set_app while it builds the app, before any script host loads, so on_start already sees them.

Until then the app directory reads as the process working directory and the id as lumen-app, which keeps a bare host in a test or in lumenc check resolving paths instead of failing.

Functions§

app_dir
The directory the app was loaded from.
app_id
The app’s stable id.
data_dir
The directory this app keeps saved data in, created when missing.
data_dir_for
The directory a given app id keeps saved data in, without touching (or creating) it and without going through the process-global published app.
data_dir_under
Join a resolved root and an app id into the one path shape every per-app data directory uses. Exposed so a caller that already holds an override root (a test, an embedder) can place a directory the same way data_dir_for does, instead of reimplementing the join.
resolve
Resolve a path an app author wrote: a relative path against the app directory, an absolute path unchanged. It is the rule the runtime already applies to the paths its script commands carry, so "data/tasks.json" names the same file wherever the app was started from.
set_app
Publish the app’s directory and its stable id ([app] id in lumen.toml, else the app directory name).