loadSettings

Load settings. Will create settings file by default. Searches all system-wide settings dirs as well as the user's settings dir, and loads the first file found.

loadSettings
(
T
alias settingsFormat = SettingsFormat
)
(
string name
,
string filename = settingsFilename
,
string subdir = ""
)

Parameters

T

Type of settings struct to load

name string

Subdirectory of settings dir to save config to. Created if nonexistent.

filename string

The filename the settings will be loaded from.

subdir string

The subdirectory that the settings will be loaded from.

Examples

struct Settings {
	bool blah;
	string text;
	string[] texts;
}
auto settings = loadSettings!Settings("testapp", "settings", "subdir");
settings.texts = ["a", "b", "c"];
saveSettings(settings, "testapp", "settings", "subdir");

auto reloadedSettings = loadSettings!Settings("testapp", "settings", "subdir");
assert(reloadedSettings == settings);
assert(reloadedSettings.texts == ["a", "b", "c"]);

Meta