MCPcopy Create free account
hub / github.com/MultiMC/Launcher / customize

Method customize

launcher/minecraft/Component.cpp:293–333  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

291}
292
293bool Component::customize()
294{
295 if(isCustom())
296 {
297 return false;
298 }
299
300 auto filename = getFilename();
301 if(!FS::ensureFilePathExists(filename))
302 {
303 return false;
304 }
305 // FIXME: get rid of this try-catch.
306 try
307 {
308 QSaveFile jsonFile(filename);
309 if(!jsonFile.open(QIODevice::WriteOnly))
310 {
311 return false;
312 }
313 auto vfile = getVersionFile();
314 if(!vfile)
315 {
316 return false;
317 }
318 auto document = OneSixVersionFormat::versionFileToJson(vfile);
319 jsonFile.write(document.toJson());
320 if(!jsonFile.commit())
321 {
322 return false;
323 }
324 m_file = vfile;
325 m_metaVersion.reset();
326 emit dataChanged();
327 }
328 catch (const Exception &error)
329 {
330 qWarning() << "Version could not be loaded:" << error.cause();
331 }
332 return true;
333}
334
335bool Component::revert()
336{

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