| 768 | } |
| 769 | |
| 770 | bool 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 | |
| 820 | bool PackProfile::installJarMods_internal(QStringList filepaths) |
| 821 | { |
nothing calls this directly
no test coverage detected