MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / loadLibrary

Method loadLibrary

gui/mainwindow.cpp:917–979  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

915}
916
917Library::Error MainWindow::loadLibrary(Library &library, const QString &filename)
918{
919 Library::Error ret;
920
921 // Try to load the library from the project folder..
922 if (mProjectFile) {
923 QString path = QFileInfo(mProjectFile->getFilename()).canonicalPath();
924 QString libpath = path+"/"+filename;
925 qDebug().noquote() << "looking for library '" + libpath + "'";
926 ret = library.load(nullptr, libpath.toLatin1());
927 if (ret.errorcode != Library::ErrorCode::FILE_NOT_FOUND)
928 return ret;
929 }
930
931 // Try to load the library from the application folder..
932 const QString appPath = QFileInfo(QCoreApplication::applicationFilePath()).canonicalPath();
933 QString libpath = appPath+"/"+filename;
934 qDebug().noquote() << "looking for library '" + libpath + "'";
935 ret = library.load(nullptr, libpath.toLatin1());
936 if (ret.errorcode != Library::ErrorCode::FILE_NOT_FOUND)
937 return ret;
938 libpath = appPath+"/cfg/"+filename;
939 qDebug().noquote() << "looking for library '" + libpath + "'";
940 ret = library.load(nullptr, libpath.toLatin1());
941 if (ret.errorcode != Library::ErrorCode::FILE_NOT_FOUND)
942 return ret;
943
944#ifdef FILESDIR
945 // Try to load the library from FILESDIR/cfg..
946 const QString filesdir = FILESDIR;
947 if (!filesdir.isEmpty()) {
948 libpath = filesdir+"/cfg/"+filename;
949 qDebug().noquote() << "looking for library '" + libpath + "'";
950 ret = library.load(nullptr, libpath.toLatin1());
951 if (ret.errorcode != Library::ErrorCode::FILE_NOT_FOUND)
952 return ret;
953 libpath = filesdir+"/"+filename;
954 qDebug().noquote() << "looking for library '" + libpath + "'";
955 ret = library.load(nullptr, libpath.toLatin1());
956 if (ret.errorcode != Library::ErrorCode::FILE_NOT_FOUND)
957 return ret;
958 }
959#endif
960
961 // Try to load the library from the cfg subfolder..
962 const QString datadir = getDataDir();
963 if (!datadir.isEmpty()) {
964 libpath = datadir+"/"+filename;
965 qDebug().noquote() << "looking for library '" + libpath + "'";
966 ret = library.load(nullptr, libpath.toLatin1());
967 if (ret.errorcode != Library::ErrorCode::FILE_NOT_FOUND)
968 return ret;
969 libpath = datadir+"/cfg/"+filename;
970 qDebug().noquote() << "looking for library '" + libpath + "'";
971 ret = library.load(nullptr, libpath.toLatin1());
972 if (ret.errorcode != Library::ErrorCode::FILE_NOT_FOUND)
973 return ret;
974 }

Callers

nothing calls this directly

Calls 3

getDataDirFunction · 0.85
isEmptyMethod · 0.80
loadMethod · 0.45

Tested by

no test coverage detected