| 1057 | } |
| 1058 | |
| 1059 | void NetworkBase::SaveGroups() |
| 1060 | { |
| 1061 | if (GetMode() == Mode::server) |
| 1062 | { |
| 1063 | auto& env = GetContext().GetPlatformEnvironment(); |
| 1064 | auto path = Path::Combine(env.GetDirectoryPath(DirBase::user), u8"groups.json"); |
| 1065 | |
| 1066 | json_t jsonGroups = json_t::array(); |
| 1067 | for (auto& group : group_list) |
| 1068 | { |
| 1069 | jsonGroups.push_back(group->toJson()); |
| 1070 | } |
| 1071 | json_t jsonGroupsCfg = { |
| 1072 | { "default_group", default_group }, |
| 1073 | { "groups", jsonGroups }, |
| 1074 | }; |
| 1075 | try |
| 1076 | { |
| 1077 | Json::WriteToFile(path, jsonGroupsCfg); |
| 1078 | } |
| 1079 | catch (const std::exception& ex) |
| 1080 | { |
| 1081 | LOG_ERROR("Unable to save %s: %s", path.c_str(), ex.what()); |
| 1082 | } |
| 1083 | } |
| 1084 | } |
| 1085 | |
| 1086 | void NetworkBase::SetupDefaultGroups() |
| 1087 | { |
no test coverage detected