MCPcopy Create free account
hub / github.com/OpenHD/OpenHD / init

Method init

OpenHD/ohd_common/inc/openhd_settings_persistent.h:108–123  ·  view source on GitHub ↗

* looks for a previously written file (base_path+unique filename). * If this file exists, create settings from it - otherwise, create default * and persist. */

Source from the content-addressed store, hash-verified

106 * and persist.
107 */
108 void init() {
109 if (!OHDFilesystemUtil::exists(_base_path)) {
110 OHDFilesystemUtil::create_directory(_base_path);
111 }
112 const auto last_settings_opt = read_last_settings();
113 if (last_settings_opt.has_value()) {
114 _settings = std::make_unique<T>(last_settings_opt.value());
115 openhd::log::info_log("Using settings in [" + get_file_path() + "]");
116 } else {
117 openhd::log::info_log("Creating default settings in [" + get_file_path() +
118 "]");
119 // create default settings and persist them for the next reboot
120 _settings = std::make_unique<T>(create_default());
121 persist_settings();
122 }
123 }
124
125 protected:
126 // NEEDS TO BE OVERRIDDEN

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected