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

Function DownloadToPathWithZenityProgress

Source/Tools/FEXRootFSFetcher/Main.cpp:526–548  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

524}
525
526bool DownloadToPathWithZenityProgress(const fextl::string& URL, const fextl::string& Path) {
527 auto filename = URL.substr(URL.find_last_of('/') + 1);
528 auto PathName = Path + filename;
529
530 // -# for progress bar
531 // -o for output file
532 // -f for silent fail
533 std::string CurlPipe = fmt::format("curl -C - -#f {} -o {} 2>&1", URL, PathName);
534 const std::string StdBuf = "stdbuf -oL tr '\\r' '\\n'";
535 const std::string SedBuf = "sed -u 's/[^0-9]*\\([0-9]*\\).*/\\1/'";
536 // zenity --auto-close can't be used since `curl -C` for whatever reason prints 100% at the start.
537 // Making zenity vanish immediately
538 const std::string ZenityBuf = "zenity --time-remaining --progress --no-cancel --title 'Downloading'";
539 std::string BigArgs = fmt::format("{} | {} | {} | {}", CurlPipe, StdBuf, SedBuf, ZenityBuf);
540 std::array<const char*, 4> ExecveArgs = {
541 "/bin/sh",
542 "-c",
543 BigArgs.c_str(),
544 nullptr,
545 };
546
547 return Exec::ExecAndWaitForResponse(ExecveArgs[0], const_cast<char* const*>(ExecveArgs.data())) == 0;
548}
549
550std::optional<std::vector<FileTargets>> GetRootFSLinks() {
551 // Decode the filetargets

Callers 1

Calls 2

formatFunction · 0.85
ExecAndWaitForResponseFunction · 0.85

Tested by

no test coverage detected