Class JSONFileBindingStorage
An IBindingStorage implementation that persists input binding overrides as individual JSON files on the file system, one file per profile.
Implements
Inherited Members
Namespace: Scylla.Input
Assembly: ScyllaInput.dll
Syntax
public class JSONFileBindingStorage : IBindingStorage
Remarks
Files are written to BasePath, which defaults to a sub-directory
named Scylla/Input inside Application.persistentDataPath. The
directory is created automatically on construction if it does not exist.
Each profile is stored in a file named bindings_{profileID}.json, where
the profile ID is first sanitized by replacing any character that is illegal in a
file name (as defined by Path.GetInvalidFileNameChars) with an underscore.
Profile enumeration via GetAllProfiles() scans the directory for files
matching this naming convention.
This backend is recommended when:
- Saved bindings must be easily inspectable or editable by players (modding support).
- The application needs to share binding files between sessions or sync them externally.
- The platform has a writable persistent data path (desktop, consoles with file system access).
All I/O operations are synchronous and wrapped in try/catch blocks. Failures are
logged via Log.Error and do not propagate exceptions to the caller.
Constructors
JSONFileBindingStorage()
Initializes a new JSONFileBindingStorage that stores binding files
under the default path (Application.persistentDataPath/Scylla/Input).
Declaration
public JSONFileBindingStorage()
JSONFileBindingStorage(string)
Initializes a new JSONFileBindingStorage with an explicit base directory path.
Declaration
public JSONFileBindingStorage(string basePath)
Parameters
| Type | Name | Description |
|---|---|---|
| string | basePath | Absolute path to the directory in which binding files will be created. When
|
Properties
BasePath
Gets the absolute path to the directory where binding JSON files are written.
Declaration
public string BasePath { get; }
Property Value
| Type | Description |
|---|---|
| string | The fully resolved base path established at construction time. Defaults to
|
StorageID
Gets a short, human-readable identifier that names this storage backend.
Declaration
public string StorageID { get; }
Property Value
| Type | Description |
|---|---|
| string | A non-null, non-empty string that uniquely identifies the backend, such as
|
Methods
DeleteBindings(string)
Permanently removes the saved binding data for the given profile.
Declaration
public bool DeleteBindings(string profileID)
Parameters
| Type | Name | Description |
|---|---|---|
| string | profileID | The non-null, non-empty string that identifies the profile to delete. |
Returns
| Type | Description |
|---|---|
| bool |
|
GetAllProfiles()
Returns the identifiers of every profile that currently has saved binding data in this storage backend.
Declaration
public IReadOnlyList<string> GetAllProfiles()
Returns
| Type | Description |
|---|---|
| IReadOnlyList<string> | A non-null, read-only list of profile ID strings. The list is empty if no profiles have been saved or if the backend cannot enumerate them. The order of entries is implementation-defined. |
HasBindings(string)
Determines whether saved binding data exists for the given profile.
Declaration
public bool HasBindings(string profileID)
Parameters
| Type | Name | Description |
|---|---|---|
| string | profileID | The profile identifier to check. Returns |
Returns
| Type | Description |
|---|---|
| bool |
|
LoadBindings(string)
Retrieves the previously saved JSON binding data for the given profile.
Declaration
public string LoadBindings(string profileID)
Parameters
| Type | Name | Description |
|---|---|---|
| string | profileID | The non-null, non-empty string that identifies the profile slot to read from. |
Returns
| Type | Description |
|---|---|
| string | The raw JSON string that was passed to SaveBindings(string, string) for this profile,
or |
SaveBindings(string, string)
Persists the supplied JSON binding data under the given profile identifier.
Declaration
public void SaveBindings(string profileID, string jsonData)
Parameters
| Type | Name | Description |
|---|---|---|
| string | profileID | The non-null, non-empty string that names the profile slot to write into (for
example |
| string | jsonData | The JSON string produced by ExportBindingsAsJSON(). Must not be null or empty; implementations should log a warning and return early if it is. |
Remarks
Implementations are expected to handle I/O failures gracefully - logging the error and returning without propagating an exception to the caller.