| 55 | } |
| 56 | |
| 57 | bool savePropertiesFile(const std::string& filePath, const std::map<std::string, std::string>& properties) { |
| 58 | bool result = false; |
| 59 | getLock(filePath)->withLock([&result, filePath, &properties] { |
| 60 | LOGGER.info("Saving properties file {}", filePath); |
| 61 | |
| 62 | FILE* file = fopen(filePath.c_str(), "w"); |
| 63 | if (file == nullptr) { |
| 64 | LOGGER.error("Failed to open {}", filePath); |
| 65 | return; |
| 66 | } |
| 67 | |
| 68 | for (const auto& [key, value]: properties) { fprintf(file, "%s=%s\n", key.c_str(), value.c_str()); } |
| 69 | |
| 70 | fclose(file); |
| 71 | result = true; |
| 72 | }); |
| 73 | return result; |
| 74 | } |
| 75 | |
| 76 | } |