MCPcopy Create free account
hub / github.com/ModOrganizer2/modorganizer / objectsForDeletion

Method objectsForDeletion

src/instancemanager.cpp:335–485  ·  view source on GitHub ↗

returns a list of files and folders that must be deleted when deleting this instance

Source from the content-addressed store, hash-verified

333// this instance
334//
335std::vector<Instance::Object> Instance::objectsForDeletion() const
336{
337 // native separators and ending slash
338 auto prettyDir = [](auto s) {
339 if (!s.endsWith("/") || !s.endsWith("\\")) {
340 s += "/";
341 }
342
343 return QDir::toNativeSeparators(s);
344 };
345
346 // native separators
347 auto prettyFile = [](auto s) {
348 return QDir::toNativeSeparators(s);
349 };
350
351 // lowercase, native separators and ending slash
352 auto canonicalDir = [](QString s) {
353 s = s.toLower();
354
355 if (!s.endsWith("/") || !s.endsWith("\\")) {
356 s += "/";
357 }
358
359 return QDir::toNativeSeparators(s);
360 };
361
362 // lower and native separators
363 auto canonicalFile = [](auto s) {
364 return QDir::toNativeSeparators(s.toLower());
365 };
366
367 // whether the given directory is contained in the root
368 auto dirInRoot = [&](const QString& root, const QString& dir) {
369 return canonicalDir(dir).startsWith(canonicalDir(root));
370 };
371
372 // whether the given file is contained in the root
373 auto fileInRoot = [&](const QString& root, const QString& file) {
374 return canonicalFile(file).startsWith(canonicalDir(root));
375 };
376
377 Settings settings(iniPath());
378
379 if (settings.iniStatus() != QSettings::NoError) {
380 log::error("can't read ini {}", iniPath());
381 return {};
382 }
383
384 const QString loc = directory();
385 const QString base = settings.paths().base();
386
387 // directories that might contain the individual files and directories
388 // set in the path settings
389 std::vector<Object> roots;
390
391 // a portable instance has its location in the installation directory,
392 // don't delete that

Callers 1

deleteInstanceMethod · 0.80

Calls 12

QDirClass · 0.85
iniStatusMethod · 0.80
baseMethod · 0.80
downloadsMethod · 0.80
modsMethod · 0.80
cacheMethod · 0.80
profilesMethod · 0.80
overwriteMethod · 0.80
existsMethod · 0.45
insertMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected