MCPcopy Create free account
hub / github.com/FreeCAD/FreeCAD / loadLibrary

Method loadLibrary

src/Mod/Material/App/MaterialLoader.cpp:543–571  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

541}
542
543void MaterialLoader::loadLibrary(const std::shared_ptr<MaterialLibraryLocal>& library)
544{
545 if (_materialEntryMap == nullptr) {
546 _materialEntryMap = std::make_unique<std::map<QString, std::shared_ptr<MaterialEntry>>>();
547 }
548
549 QDirIterator it(library->getDirectory(), QDirIterator::Subdirectories);
550 while (it.hasNext()) {
551 auto pathname = it.next();
552 QFileInfo file(pathname);
553 if (file.isFile()) {
554 if (file.suffix().toStdString() == "FCMat") {
555 try {
556 auto model = getMaterialFromPath(library, file.canonicalFilePath());
557 if (model) {
558 (*_materialEntryMap)[model->getUUID()] = model;
559 }
560 }
561 catch (const MaterialReadError&) {
562 // Ignore the file. Error messages should have already been logged
563 }
564 }
565 }
566 }
567
568 for (auto& it : *_materialEntryMap) {
569 it.second->addToTree(_materialMap);
570 }
571}
572
573void MaterialLoader::loadLibraries(
574 const std::shared_ptr<std::list<std::shared_ptr<MaterialLibrary>>>& libraryList)

Callers

nothing calls this directly

Calls 6

isFileMethod · 0.80
toStdStringMethod · 0.80
addToTreeMethod · 0.80
getDirectoryMethod · 0.45
nextMethod · 0.45
getUUIDMethod · 0.45

Tested by

no test coverage detected