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

Method installCustomJar_internal

launcher/minecraft/PackProfile.cpp:837–890  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

835}
836
837bool 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
892bool PackProfile::installAgents_internal(QStringList filepaths)
893{

Callers

nothing calls this directly

Calls 15

PathCombineFunction · 0.85
ensureFolderPathExistsFunction · 0.85
GradleSpecifierClass · 0.85
deletePathFunction · 0.85
copyClass · 0.85
instanceRootMethod · 0.80
getLocalLibraryPathMethod · 0.80
getFileNameMethod · 0.80
existsMethod · 0.80
setRawNameMethod · 0.80
setDisplayNameMethod · 0.80
setHintMethod · 0.80

Tested by

no test coverage detected