| 344 | } |
| 345 | |
| 346 | void wtRebuildConfiguration(bool withCustom = false) |
| 347 | { |
| 348 | /* Reset and apply the format configuration. */ |
| 349 | |
| 350 | auto formatName = |
| 351 | readSettingFromUiThread<std::string>("format.selected", "ibm"); |
| 352 | if (formatName.empty()) |
| 353 | return; |
| 354 | globalConfig().clear(); |
| 355 | globalConfig().readBaseConfigFile("_global_options"); |
| 356 | globalConfig().readBaseConfigFile(formatName); |
| 357 | |
| 358 | /* Device-specific settings. */ |
| 359 | |
| 360 | auto device = readSettingFromUiThread<std::string>("device", "fluxfile"); |
| 361 | if (device.empty()) |
| 362 | return; |
| 363 | if (device == "fluxfile") |
| 364 | { |
| 365 | auto fluxfile = |
| 366 | readSettingFromUiThread<std::fs::path>("fluxfile", "unset") |
| 367 | .string(); |
| 368 | globalConfig().setFluxSink(fluxfile); |
| 369 | globalConfig().setFluxSource(fluxfile); |
| 370 | globalConfig().setVerificationFluxSource(fluxfile); |
| 371 | } |
| 372 | else |
| 373 | { |
| 374 | auto highDensity = readSettingFromUiThread<bool>("highDensity", true); |
| 375 | globalConfig().overrides()->mutable_drive()->set_high_density( |
| 376 | highDensity); |
| 377 | |
| 378 | if (device[0] == '#') |
| 379 | { |
| 380 | auto serial = device.substr(1); |
| 381 | globalConfig().overrides()->mutable_usb()->set_serial(serial); |
| 382 | globalConfig().setFluxSink("drive:0"); |
| 383 | globalConfig().setFluxSource("drive:0"); |
| 384 | globalConfig().setVerificationFluxSource("drive:0"); |
| 385 | } |
| 386 | } |
| 387 | |
| 388 | /* Selected options. */ |
| 389 | |
| 390 | auto options = stringToOptions( |
| 391 | readSettingFromUiThread<std::string>("globalSettings", "")); |
| 392 | options.merge( |
| 393 | stringToOptions(readSettingFromUiThread<std::string>(formatName, ""))); |
| 394 | |
| 395 | for (const auto& [key, value] : options) |
| 396 | globalConfig().applyOption(key, value); |
| 397 | |
| 398 | /* Custom settings. */ |
| 399 | |
| 400 | globalConfig().applyOptionsFile( |
| 401 | readSettingFromUiThread<std::string>("systemProperties", "")); |
| 402 | globalConfig().applyOptionsFile( |
| 403 | readSettingFromUiThread<std::string>("custom", "")); |
no test coverage detected