Loop through files
| 17 | |
| 18 | //Loop through files |
| 19 | foreach (QFileInfo entry, entries) { |
| 20 | if (entry.isDir()) { |
| 21 | //If the entry is a folder, call the browseRecursively function again |
| 22 | QDir dir(entry.filePath()); |
| 23 | QString mainClass = getMainClassPath(dir); |
| 24 | if (!mainClass.isEmpty()) |
| 25 | return mainClass; |
| 26 | } else { |
| 27 | //If the file is not a folder, then check if it has the .class extension |
| 28 | if (entry.suffix().toLower() == "class") { |
| 29 | qInfo() << entry.fileName(); |
| 30 | |
| 31 | if (QStandardPaths::findExecutable("javap").isEmpty()) { |
| 32 | auto winSrv = dpfGetService(dpfservice::WindowService); |
| 33 | winSrv->notify(2, "Java", tr("Unable to find the javap application. Please install openjdk-11-jdk or another version first."), {}); |
| 34 | return {}; |
| 35 | } |
| 36 | |
| 37 | QProcess process; |
| 38 | auto temp = entry.filePath(); |
| 39 | process.start("javap " + entry.filePath()); |
| 40 | if(!process.waitForFinished()) { |
| 41 | qDebug() << "process is error!"; |
| 42 | break; |
| 43 | } |
| 44 | QString output = process.readAllStandardOutput(); |
| 45 | //Check if the given regular expression matches the file content |
| 46 | if (regExp.indexIn(output) >= 0) { |
| 47 | return entry.filePath(); |
| 48 | } |
| 49 | } |
| 50 | } |
| 51 | } |
| 52 | return {}; |
| 53 | } |
| 54 |
no test coverage detected