MCPcopy Create free account
hub / github.com/FreesmTeam/FreesmLauncher / removeComponent_internal

Method removeComponent_internal

launcher/minecraft/PackProfile.cpp:740–782  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

738}
739
740bool PackProfile::removeComponent_internal(ComponentPtr patch)
741{
742 bool ok = true;
743 // first, remove the patch file. this ensures it's not used anymore
744 auto fileName = patch->getFilename();
745 if (fileName.size()) {
746 QFile patchFile(fileName);
747 if (patchFile.exists() && !patchFile.remove()) {
748 qCCritical(instanceProfileC) << d->m_instance->name() << "|" << "File" << fileName
749 << "could not be removed because:" << patchFile.errorString();
750 return false;
751 }
752 }
753
754 // FIXME: we need a generic way of removing local resources, not just jar mods...
755 auto preRemoveJarMod = [&](LibraryPtr jarMod) -> bool {
756 if (!jarMod->isLocal()) {
757 return true;
758 }
759 QStringList jar, temp1, temp2, temp3;
760 jarMod->getApplicableFiles(d->m_instance->runtimeContext(), jar, temp1, temp2, temp3, d->m_instance->jarmodsPath().absolutePath());
761 QFileInfo finfo(jar[0]);
762 if (finfo.exists()) {
763 QFile jarModFile(jar[0]);
764 if (!jarModFile.remove()) {
765 qCCritical(instanceProfileC) << d->m_instance->name() << "|" << "File" << jar[0]
766 << "could not be removed because:" << jarModFile.errorString();
767 return false;
768 }
769 return true;
770 }
771 return true;
772 };
773
774 auto vFile = patch->getVersionFile();
775 if (vFile) {
776 auto& jarMods = vFile->jarMods;
777 for (auto& jarmod : jarMods) {
778 ok &= preRemoveJarMod(jarmod);
779 }
780 }
781 return ok;
782}
783
784bool PackProfile::installJarMods_internal(QStringList filepaths)
785{

Callers

nothing calls this directly

Calls 11

getFilenameMethod · 0.80
existsMethod · 0.80
errorStringMethod · 0.80
isLocalMethod · 0.80
getApplicableFilesMethod · 0.80
jarmodsPathMethod · 0.80
getVersionFileMethod · 0.80
sizeMethod · 0.45
removeMethod · 0.45
nameMethod · 0.45
runtimeContextMethod · 0.45

Tested by

no test coverage detected