| 31 | #include "openhd_util_filesystem.h" |
| 32 | |
| 33 | std::string openhd::getOrCreateUnitId() { |
| 34 | generateSettingsDirectoryIfNonExists(); |
| 35 | auto unit_id_opt = OHDFilesystemUtil::opt_read_file(get_unit_id_file_path()); |
| 36 | if (unit_id_opt.has_value()) { |
| 37 | std::string unit_id = unit_id_opt.value(); |
| 38 | // openhd::log::get_default()->debug("Read unit id:{}",unit_id); |
| 39 | return unit_id; |
| 40 | } |
| 41 | // No unit id exists yet - create new one |
| 42 | // generate new unit id |
| 43 | // See https://www.boost.org/doc/libs/1_62_0/libs/uuid/uuid.html |
| 44 | // const boost::uuids::uuid _uuid = boost::uuids::random_generator()(); |
| 45 | // unit_id = to_string(_uuid); |
| 46 | std::string unit_id = create_unit_it_temporary(); |
| 47 | OHDFilesystemUtil::write_file(get_unit_id_file_path(), unit_id); |
| 48 | openhd::log::get_default()->info("Created new unit id:{}", unit_id); |
| 49 | return unit_id; |
| 50 | } |
| 51 | |
| 52 | void openhd::clean_all_settings() { |
| 53 | openhd::log::get_default()->debug("clean_all_settings()"); |
nothing calls this directly
no test coverage detected