| 773 | } |
| 774 | |
| 775 | bool ValidateDownloadSelection(const WebFileFetcher::FileTargets& Target) { |
| 776 | fextl::string Text = fextl::fmt::format("Selected Rootfs: {}\n", Target.DistroName); |
| 777 | Text += fmt::format("\tURL: {}\n", Target.URL); |
| 778 | Text += fmt::format("Are you sure that you want to download this image"); |
| 779 | |
| 780 | if (AskForConfirmation(Text)) { |
| 781 | fextl::string RootFS = FEXCore::Config::GetDataDirectory() + "RootFS/"; |
| 782 | std::error_code ec {}; |
| 783 | if (!std::filesystem::exists(RootFS, ec)) { |
| 784 | // Doesn't exist, create the the folder as a user convenience |
| 785 | if (!std::filesystem::create_directories(RootFS, ec)) { |
| 786 | // Well I guess we failed |
| 787 | Text = fmt::format("Couldn't create {} path for storing RootFS", RootFS); |
| 788 | ExecWithInfo(Text); |
| 789 | return false; |
| 790 | } |
| 791 | } |
| 792 | |
| 793 | if (!WebFileFetcher::DownloadToPathWithZenityProgress(Target.URL, RootFS)) { |
| 794 | return false; |
| 795 | } |
| 796 | |
| 797 | return true; |
| 798 | } |
| 799 | return false; |
| 800 | } |
| 801 | } // namespace Zenity |
| 802 | |
| 803 | namespace TTY { |
no test coverage detected