Class ConfigFileUtil
Provides file I/O and path resolution utilities for ConfigFile instances, supporting the Scylla framework's four-tier layered configuration system. The four tiers, from highest to lowest priority, are: User Documents, Application folder, Unity Asset, and compiled defaults. This class handles the two filesystem tiers - User Documents and Application folder - by constructing their canonical paths and performing JSON-based load and save operations.
All load operations are non-throwing: a missing file, empty file, or JSON parse failure
each return null with a warning logged to the Core log category. Save operations
return a bool indicating success and log a warning on failure rather than throwing.
Parent directories are created automatically on save.
Config file paths follow the convention
{BasePath}/Config/{configBaseName}.json, where configBaseName identifies
the owning module or subsystem (e.g. "Core", "Input", "Logger").
Use GetUserDocumentsConfigPath(string) for the User Documents tier and
GetAppFolderConfigPath(string) for the Application folder tier.
Inherited Members
Namespace: Scylla.Core.Util.File
Assembly: ScyllaCore.dll
Syntax
public static class ConfigFileUtil
Fields
CONFIG_FILE_EXTENSION
The file extension (including the leading dot) used for all Scylla config files
(value: ".json"). Config files are stored as human-readable, pretty-printed JSON
as produced by ToJSON().
Declaration
public const string CONFIG_FILE_EXTENSION = ".json"
Field Value
| Type | Description |
|---|---|
| string |
CONFIG_SUBFOLDER
The name of the subdirectory within the application executable folder or the user
documents product folder where Scylla config files are stored (value: "Config").
This constant is used by GetUserDocumentsConfigPath(string) and
GetAppFolderConfigPath(string) to construct canonical config file paths.
Declaration
public const string CONFIG_SUBFOLDER = "Config"
Field Value
| Type | Description |
|---|---|
| string |
Methods
GetAppFolderConfigPath(string)
Constructs the canonical Application folder config file path for the given config base
name, placing it in a Config subdirectory next to the application executable.
This corresponds to the second-priority tier in the Scylla four-tier layered config
system, allowing system administrators or build pipelines to distribute per-installation
overrides without modifying per-user documents.
Declaration
public static string GetAppFolderConfigPath(string configBaseName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | configBaseName | The config base name that identifies the module or subsystem owning the config file,
for example |
Returns
| Type | Description |
|---|---|
| string | The full path in the format |
GetUserDocumentsConfigPath(string)
Constructs the canonical User Documents config file path for the given config base name, placing it within a per-product subdirectory of the platform's My Documents folder. This corresponds to the highest-priority tier in the Scylla four-tier layered config system, allowing end users to override application-level and compiled defaults.
Declaration
public static string GetUserDocumentsConfigPath(string configBaseName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | configBaseName | The config base name that identifies the module or subsystem owning the config file,
for example |
Returns
| Type | Description |
|---|---|
| string | The full path in the format
|
Load(string)
Loads a ConfigFile from the specified file path by reading its JSON content
and deserializing it via FromJSON(string). This method is non-throwing:
any failure silently returns null and logs a warning to the Core log category.
Declaration
public static ConfigFile Load(string path)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | The absolute file path to load from. If |
Returns
| Type | Description |
|---|---|
| ConfigFile | The deserialized ConfigFile instance if the file exists, is non-empty, and
contains valid JSON; otherwise |
Save(string, ConfigFile)
Serializes a ConfigFile to JSON and writes it to the specified file path,
creating any missing parent directories automatically. This method is non-throwing: any
failure is logged as a warning to the Core log category and returns false.
Declaration
public static bool Save(string path, ConfigFile configFile)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | The absolute file path to write to. If |
| ConfigFile | configFile | The ConfigFile instance to serialize and save. If |
Returns
| Type | Description |
|---|---|
| bool |
|
TryLoad(string, out ConfigFile)
Attempts to load a ConfigFile from the specified file path, providing a
bool return value that is suitable for use in if and out patterns.
Internally delegates to Load(string); all failure conditions that cause
Load(string) to return null will cause this method to return false.
Declaration
public static bool TryLoad(string path, out ConfigFile configFile)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | The absolute file path to load from. If |
| ConfigFile | configFile | When this method returns |
Returns
| Type | Description |
|---|---|
| bool |
|