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

Method customize

launcher/minecraft/Component.cpp:330–362  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

328}
329
330bool Component::customize()
331{
332 if (isCustom()) {
333 return false;
334 }
335
336 auto filename = getFilename();
337 if (!FS::ensureFilePathExists(filename)) {
338 return false;
339 }
340 // FIXME: get rid of this try-catch.
341 try {
342 QSaveFile jsonFile(filename);
343 if (!jsonFile.open(QIODevice::WriteOnly)) {
344 return false;
345 }
346 auto vfile = getVersionFile();
347 if (!vfile) {
348 return false;
349 }
350 auto document = OneSixVersionFormat::versionFileToJson(vfile);
351 jsonFile.write(document.toJson());
352 if (!jsonFile.commit()) {
353 return false;
354 }
355 m_file = vfile;
356 m_metaVersion.reset();
357 emit dataChanged();
358 } catch (const Exception& error) {
359 qWarning() << "Version could not be loaded:" << error.cause();
360 }
361 return true;
362}
363
364bool Component::revert()
365{

Callers 1

Calls 6

ensureFilePathExistsFunction · 0.85
openMethod · 0.80
toJsonMethod · 0.80
causeMethod · 0.80
writeMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected