MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / startUsedByScan

Method startUsedByScan

apps/tools/Studio/StudioApp.cpp:426–642  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

424}
425
426void StudioApp::startUsedByScan()
427{
428 if (usedByScanning)
429 return;
430
431 usedByCancelFlag = true;
432 if (usedByThread.joinable())
433 usedByThread.join();
434 usedByCancelFlag = false;
435
436 std::string texName;
437 if (selectedEntry.isVirtual())
438 texName = normalizePath(selectedEntry.pboFilename);
439 else
440 texName = normalizePath(selectedEntry.name);
441 if (texName.empty())
442 return;
443
444 std::string texBasename = texName;
445 auto lastSlash = texBasename.rfind('/');
446 if (lastSlash != std::string::npos)
447 texBasename = texBasename.substr(lastSlash + 1);
448
449 std::string selExt = selectedEntry.extension;
450 std::transform(selExt.begin(), selExt.end(), selExt.begin(), ::tolower);
451 bool scanModels =
452 (selExt == ".paa" || selExt == ".pac" || selExt == ".tga" || selExt == ".jpg" || selExt == ".png");
453 bool scanFonts = scanModels;
454
455 usedByScanKey = selectedFile;
456 usedByScanning = true;
457 usedByScanDone = false;
458 usedByScanProgress = 0;
459 {
460 std::lock_guard<std::mutex> lk(usedByMutex);
461 assetUsedBy.clear();
462 }
463
464 // Engine types (QFBank, RString, Ref<>) are NOT thread-safe, so all PBO
465 // extraction must happen here on the main thread before spawning the scan.
466 struct ScanItem
467 {
468 std::string name;
469 std::string inspectPath;
470 std::string extension;
471 bool needsCleanup;
472 };
473 std::vector<ScanItem> scanItems;
474
475 std::unordered_map<std::string, std::vector<std::pair<int, std::string>>> pboGroups;
476
477 for (const auto* list : {&osFiles, &vfsFiles})
478 {
479 for (const auto& f : *list)
480 {
481 std::string ext = f.extension;
482 std::transform(ext.begin(), ext.end(), ext.begin(), ::tolower);
483 if (!((scanModels && ext == ".p3d") || (scanFonts && ext == ".fxy")))

Callers

nothing calls this directly

Calls 15

normalizePathFunction · 0.85
InspectModelFunction · 0.85
InspectFontFunction · 0.85
isVirtualMethod · 0.80
clearMethod · 0.80
sizeMethod · 0.80
StripPboExtensionFunction · 0.70
RStringClass · 0.50
emptyMethod · 0.45
openMethod · 0.45
LockMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected