MCPcopy Create free account
hub / github.com/danoon2/Boxedwine / updateFileList

Method updateFileList

source/ui/data/globalSettings.cpp:637–720  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

635}
636
637void GlobalSettings::updateFileList(BString fileLocation) {
638 runInBackgroundThread([fileLocation]() {
639 bool changed = false;
640 GlobalSettings::filesListDownloading = true;
641
642 for (auto& url : GlobalSettings::fileUrls) {
643 BString name = Fs::getFileNameFromPath(url);
644 BString path = fileLocation + name;
645 BString tmpPath = fileLocation + "tmp.xml";
646 unsigned int oldcrc = crc32File(path);
647 BString errorMsg;
648 GlobalSettings::filesListDownloading = true;
649 if (::downloadFile(url, tmpPath, [](U64 bytesCompleted) {
650 }, nullptr, errorMsg)) {
651 if (Fs::doesNativePathExist(path)) {
652 Fs::deleteNativeFile(path);
653 }
654 static_cast<void>(::rename(tmpPath.c_str(), path.c_str())); // ignore return result
655 unsigned int newcrc = crc32File(path);
656 if (newcrc != oldcrc) {
657 changed = true;
658 }
659 }
660
661
662 }
663 runOnMainUI([changed]() {
664 GlobalSettings::loadFileLists();
665 GlobalSettings::filesListDownloading = false;
666 runInBackgroundThread([changed]() {
667 BString errorMsg;
668
669 for (auto& demo : GlobalSettings::getDemos()) {
670 if (demo->iconPath.length()) {
671 int pos = demo->iconPath.lastIndexOf('/');
672 if (pos == -1) {
673 continue; // :TODO: error msg?
674 }
675 if (!Fs::doesNativePathExist(GlobalSettings::getDemoFolder())) {
676 Fs::makeNativeDirs(GlobalSettings::getDemoFolder());
677 }
678 if (!Fs::doesNativePathExist(demo->localIconPath)) {
679 ::downloadFile(demo->iconPath, demo->localIconPath, [](U64 bytesCompleted) {
680 }, nullptr, errorMsg);
681 runOnMainUI([&demo]() {
682 demo->buildIconTexture();
683 return false;
684 });
685 }
686 }
687 }
688 if (changed) {
689 upgradeAvailable.clear();
690 BString wineLabel;
691 for (auto& ver : GlobalSettings::fileSystemVersions) {
692 for (auto& avail : GlobalSettings::availableFileSystemVersions) {
693 if (ver->name == avail->name && ver->fsVersion != avail->fsVersion) {
694 upgradeAvailable.push_back(avail);

Callers

nothing calls this directly

Calls 14

runInBackgroundThreadFunction · 0.85
crc32FileFunction · 0.85
downloadFileFunction · 0.85
renameFunction · 0.85
runOnMainUIFunction · 0.85
getTranslationWithFormatFunction · 0.85
doUpgradeFunction · 0.85
lastIndexOfMethod · 0.80
buildIconTextureMethod · 0.80
c_strMethod · 0.45
lengthMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected