MCPcopy Create free account
hub / github.com/PolyMC/PolyMC / customize

Method customize

launcher/minecraft/Component.cpp:328–368  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

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