MCPcopy Create free account
hub / github.com/PolyMC/PolyMC / removeComponent_internal

Method removeComponent_internal

launcher/minecraft/PackProfile.cpp:770–818  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

768}
769
770bool PackProfile::removeComponent_internal(ComponentPtr patch)
771{
772 bool ok = true;
773 // first, remove the patch file. this ensures it's not used anymore
774 auto fileName = patch->getFilename();
775 if(fileName.size())
776 {
777 QFile patchFile(fileName);
778 if(patchFile.exists() && !patchFile.remove())
779 {
780 qCritical() << "File" << fileName << "could not be removed because:" << patchFile.errorString();
781 return false;
782 }
783 }
784
785 // FIXME: we need a generic way of removing local resources, not just jar mods...
786 auto preRemoveJarMod = [&](LibraryPtr jarMod) -> bool
787 {
788 if (!jarMod->isLocal())
789 {
790 return true;
791 }
792 QStringList jar, temp1, temp2, temp3;
793 jarMod->getApplicableFiles(d->m_instance->runtimeContext(), jar, temp1, temp2, temp3, d->m_instance->jarmodsPath().absolutePath());
794 QFileInfo finfo (jar[0]);
795 if(finfo.exists())
796 {
797 QFile jarModFile(jar[0]);
798 if(!jarModFile.remove())
799 {
800 qCritical() << "File" << jar[0] << "could not be removed because:" << jarModFile.errorString();
801 return false;
802 }
803 return true;
804 }
805 return true;
806 };
807
808 auto vFile = patch->getVersionFile();
809 if(vFile)
810 {
811 auto &jarMods = vFile->jarMods;
812 for(auto &jarmod: jarMods)
813 {
814 ok &= preRemoveJarMod(jarmod);
815 }
816 }
817 return ok;
818}
819
820bool PackProfile::installJarMods_internal(QStringList filepaths)
821{

Callers

nothing calls this directly

Calls 9

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

Tested by

no test coverage detected