| 835 | } |
| 836 | |
| 837 | bool PackProfile::installCustomJar_internal(QString filepath) |
| 838 | { |
| 839 | QString patchDir = FS::PathCombine(d->m_instance->instanceRoot(), "patches"); |
| 840 | if (!FS::ensureFolderPathExists(patchDir)) { |
| 841 | return false; |
| 842 | } |
| 843 | |
| 844 | QString libDir = d->m_instance->getLocalLibraryPath(); |
| 845 | if (!FS::ensureFolderPathExists(libDir)) { |
| 846 | return false; |
| 847 | } |
| 848 | |
| 849 | auto specifier = GradleSpecifier("custom:customjar:1"); |
| 850 | QFileInfo sourceInfo(filepath); |
| 851 | QString target_filename = specifier.getFileName(); |
| 852 | QString target_id = specifier.artifactId(); |
| 853 | QString target_name = sourceInfo.completeBaseName() + " (custom jar)"; |
| 854 | QString finalPath = FS::PathCombine(libDir, target_filename); |
| 855 | |
| 856 | QFileInfo jarInfo(finalPath); |
| 857 | if (jarInfo.exists()) { |
| 858 | if (!FS::deletePath(finalPath)) { |
| 859 | return false; |
| 860 | } |
| 861 | } |
| 862 | if (!QFile::copy(filepath, finalPath)) { |
| 863 | return false; |
| 864 | } |
| 865 | |
| 866 | auto f = std::make_shared<VersionFile>(); |
| 867 | auto jarMod = std::make_shared<Library>(); |
| 868 | jarMod->setRawName(specifier); |
| 869 | jarMod->setDisplayName(sourceInfo.completeBaseName()); |
| 870 | jarMod->setHint("local"); |
| 871 | f->mainJar = jarMod; |
| 872 | f->name = target_name; |
| 873 | f->uid = target_id; |
| 874 | QString patchFileName = FS::PathCombine(patchDir, target_id + ".json"); |
| 875 | |
| 876 | QFile file(patchFileName); |
| 877 | if (!file.open(QFile::WriteOnly)) { |
| 878 | qCCritical(instanceProfileC) << d->m_instance->name() << "|" << "Error opening" << file.fileName() |
| 879 | << "for reading:" << file.errorString(); |
| 880 | return false; |
| 881 | } |
| 882 | file.write(OneSixVersionFormat::versionFileToJson(f).toJson()); |
| 883 | file.close(); |
| 884 | |
| 885 | appendComponent(makeShared<Component>(this, f->uid, f)); |
| 886 | |
| 887 | scheduleSave(); |
| 888 | invalidateLaunchProfile(); |
| 889 | return true; |
| 890 | } |
| 891 | |
| 892 | bool PackProfile::installAgents_internal(QStringList filepaths) |
| 893 | { |
nothing calls this directly
no test coverage detected