| 975 | } |
| 976 | |
| 977 | bool PackProfile::removeComponent_internal(ComponentPtr patch) |
| 978 | { |
| 979 | bool ok = true; |
| 980 | // first, remove the patch file. this ensures it's not used anymore |
| 981 | auto fileName = patch->getFilename(); |
| 982 | if(fileName.size()) |
| 983 | { |
| 984 | QFile patchFile(fileName); |
| 985 | if(patchFile.exists() && !patchFile.remove()) |
| 986 | { |
| 987 | qCritical() << "File" << fileName << "could not be removed because:" << patchFile.errorString(); |
| 988 | return false; |
| 989 | } |
| 990 | } |
| 991 | |
| 992 | // FIXME: we need a generic way of removing local resources, not just jar mods... |
| 993 | auto preRemoveJarMod = [&](LibraryPtr jarMod) -> bool |
| 994 | { |
| 995 | if (!jarMod->isLocal()) |
| 996 | { |
| 997 | return true; |
| 998 | } |
| 999 | QStringList jar, temp1, temp2, temp3; |
| 1000 | jarMod->getApplicableFiles(currentSystem, jar, temp1, temp2, temp3, d->m_instance->jarmodsPath().absolutePath()); |
| 1001 | QFileInfo finfo (jar[0]); |
| 1002 | if(finfo.exists()) |
| 1003 | { |
| 1004 | QFile jarModFile(jar[0]); |
| 1005 | if(!jarModFile.remove()) |
| 1006 | { |
| 1007 | qCritical() << "File" << jar[0] << "could not be removed because:" << jarModFile.errorString(); |
| 1008 | return false; |
| 1009 | } |
| 1010 | return true; |
| 1011 | } |
| 1012 | return true; |
| 1013 | }; |
| 1014 | |
| 1015 | auto vFile = patch->getVersionFile(); |
| 1016 | if(vFile) |
| 1017 | { |
| 1018 | auto &jarMods = vFile->jarMods; |
| 1019 | for(auto &jarmod: jarMods) |
| 1020 | { |
| 1021 | ok &= preRemoveJarMod(jarmod); |
| 1022 | } |
| 1023 | } |
| 1024 | return ok; |
| 1025 | } |
| 1026 | |
| 1027 | bool PackProfile::installJarMods_internal(QStringList filepaths) |
| 1028 | { |
nothing calls this directly
no test coverage detected