| 69 | } |
| 70 | |
| 71 | void BackupSettingsOfCurrentVersion() |
| 72 | { |
| 73 | auto sceneCollectionName = obs_frontend_get_current_scene_collection(); |
| 74 | const std::string fileName = |
| 75 | std::string("settings-backup-") + |
| 76 | (sceneCollectionName ? sceneCollectionName : "-") + "-" + |
| 77 | g_GIT_TAG + ".json"; |
| 78 | bfree(sceneCollectionName); |
| 79 | auto settingsFile = obs_module_config_path(fileName.c_str()); |
| 80 | if (!settingsFile) { |
| 81 | return; |
| 82 | } |
| 83 | |
| 84 | QString dirPath = QFileInfo(settingsFile).absolutePath(); |
| 85 | QDir dir(dirPath); |
| 86 | if (!dir.exists()) { |
| 87 | if (!dir.mkpath(dirPath)) { |
| 88 | blog(LOG_WARNING, |
| 89 | "failed to create directory to save automated backup"); |
| 90 | bfree(settingsFile); |
| 91 | return; |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | QFile file(settingsFile); |
| 96 | if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { |
| 97 | bfree(settingsFile); |
| 98 | return; |
| 99 | } |
| 100 | |
| 101 | OBSDataAutoRelease data = obs_data_create(); |
| 102 | SavePluginSettings(data); |
| 103 | |
| 104 | auto settings = obs_data_get_json(data); |
| 105 | QString settingsString = QString(settings ? settings : ""); |
| 106 | |
| 107 | auto out = QTextStream(&file); |
| 108 | out << settingsString; |
| 109 | bfree(settingsFile); |
| 110 | } |
| 111 | |
| 112 | } // namespace advss |
no test coverage detected