Skip to content

Module Storage

Алексей . edited this page Oct 22, 2026 · 3 revisions

Storage paths are based on module IDs, not necessarily plugin IDs or folder names. The default provider uses <GameDir>/SF/<moduleId>/ for Assets and <MyDocuments>/GTA San Andreas User Files/SF/<moduleId>/ for UserData. Config is config.json in UserData. Plugin discovery uses SF/modules/<folder>/, which is a different path.

Files and configuration

Inspect Assets.Root, UserData.Root and Config.Location instead of guessing. A plugin shipping assets beside its DLL must resolve that location explicitly or use an override supplied to it. The process working directory is not a reliable game-directory source.

IModuleStorage accepts relative paths, exposes IsReadOnly and provides file streams, text/byte convenience methods and enumeration. Do not escape the storage root with parent traversal. Keep large synchronous I/O off native callbacks.

IModuleConfig.Load/Save require source-generated JsonTypeInfo<T>. Load creates and saves defaults when the file does not exist. Malformed JSON can throw; TryLoad is not a blanket exception suppressor. There is no implicit schema migration or concurrent write-merging mechanism. Own configuration updates and migrate schemas explicitly.

For dynamic dictionaries, parse and validate a new snapshot before publishing it. Keep the previous valid snapshot on a reported reload failure rather than silently disabling detection. Track asynchronous reload commands and drain writers before unload.

See full examples, IModuleConfig, default paths and ConfigCounter.

Clone this wiki locally