Merge pull request #2282 from encounter/mods-data-dir

Add HostService.data_dir
This commit is contained in:
TakaRikka
2026-08-07 03:42:53 -07:00
committed by GitHub
5 changed files with 73 additions and 13 deletions
+12 -3
View File
@@ -13,7 +13,7 @@
#define HOST_SERVICE_ID "dev.twilitrealm.dusklight.host"
#define HOST_SERVICE_MAJOR 2u
#define HOST_SERVICE_MINOR 1u
#define HOST_SERVICE_MINOR 2u
/*
* Ignore unknown values: later service minors may add events.
@@ -96,15 +96,24 @@ typedef struct HostService {
ModContext* ctx, ModLifecycleFn fn, void* user_data, uint64_t* out_handle);
ModResult (*unwatch_mod_lifecycle)(ModContext* ctx, uint64_t handle);
/* Minor version 1 */
/*
* Read-only directory containing this platform's packaged native runtime: the mod module
* and any RUNTIME_LIBRARIES. The path is absolute and remains valid until mod_shutdown
* returns. Libraries loaded dynamically from here are owned by the mod and must be unloaded
* during mod_shutdown.
*
* Added in minor version 1.
*/
const char* (*native_dir)(ModContext* ctx);
/* Minor version 2 */
/*
* A persistent writable directory reserved for the calling mod, created on first use.
*
* The returned path remains valid until mod_shutdown returns. *out_path is null on failure.
*/
ModResult (*data_dir)(ModContext* ctx, const char** out_path);
} HostService;
MOD_DECLARE_SERVICE(HostService, svc_host, HOST_SERVICE_ID, HOST_SERVICE_MAJOR, HOST_SERVICE_MINOR);
+2 -1
View File
@@ -8,7 +8,8 @@
/*
* Read-only access to the res/ tree of the calling mod's own bundle. Reload serves the new
* bundle's contents. For writable storage, use HostService::mod_dir.
* bundle's contents. Use HostService::data_dir for persistent storage or HostService::mod_dir
* for temporary storage.
*/
#define RESOURCE_SERVICE_ID "dev.twilitrealm.dusklight.resource"