MCPcopy Create free account
hub / github.com/FEX-Emu/FEX / AskForDistroSelection

Function AskForDistroSelection

Source/Tools/FEXRootFSFetcher/Main.cpp:694–734  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

692}
693
694int32_t AskForDistroSelection(DistroQuery::DistroInfo& Info, const std::span<const WebFileFetcher::FileTargets> Targets) {
695 // Search for an exact match
696 int32_t DistroIndex = -1;
697 if (!Info.Unknown) {
698 for (size_t i = 0; i < Targets.size(); ++i) {
699 const auto& Target = Targets[i];
700
701 bool ExactMatch = Target.DistroMatch == Info.DistroName && (Info.RollingRelease || Target.VersionMatch == Info.DistroVersion);
702 if (ExactMatch) {
703 fextl::string Question = fextl::fmt::format("Found exact match for distro '{}'. Do you want to select this image?", Target.DistroName);
704 if (ExecWithQuestion(Question)) {
705 DistroIndex = i;
706 break;
707 }
708 }
709 }
710 }
711
712 if (DistroIndex != -1) {
713 return DistroIndex;
714 }
715
716 if (ArgOptions::DistroListOption == ArgOptions::ListQueryOption::OPTION_FIRST) {
717 // Return the first option if not an exact match.
718 return 0;
719 }
720
721 std::vector<std::string> Args;
722
723 Args.emplace_back("--column=Index");
724 Args.emplace_back("--column=Distro");
725 Args.emplace_back("--hide-column=1");
726 for (size_t i = 0; i < Targets.size(); ++i) {
727 const auto& Target = Targets[i];
728 Args.emplace_back(std::to_string(i));
729 Args.emplace_back(Target.DistroName);
730 }
731
732 std::string Text = "RootFS list selection";
733 return AskForComplexConfirmationList(Text, Args);
734}
735
736bool ValidateCheckExists(const WebFileFetcher::FileTargets& Target) {
737 fextl::string RootFS = FEXCore::Config::GetDataDirectory() + "RootFS/";

Callers 1

mainFunction · 0.85

Calls 8

formatFunction · 0.85
ExecWithQuestionFunction · 0.85
to_stringFunction · 0.85
AskForConfirmationFunction · 0.85
AskForConfirmationListFunction · 0.85
GetDistroInfoFunction · 0.70
sizeMethod · 0.45

Tested by

no test coverage detected