| 42 | } |
| 43 | |
| 44 | void SymlinkTask::executeTask() |
| 45 | { |
| 46 | setStatus(tr("Checking for Java binary path")); |
| 47 | const auto binPath = FS::PathCombine("bin", "java"); |
| 48 | const auto wantedPath = FS::PathCombine(m_path, binPath); |
| 49 | if (QFileInfo::exists(wantedPath)) { |
| 50 | emitSucceeded(); |
| 51 | return; |
| 52 | } |
| 53 | |
| 54 | setStatus(tr("Searching for Java binary path")); |
| 55 | const auto contentsPartialPath = FS::PathCombine("Contents", "Home", binPath); |
| 56 | const auto relativePathToBin = findBinPath(m_path, contentsPartialPath); |
| 57 | if (relativePathToBin.isEmpty()) { |
| 58 | emitFailed(tr("Failed to find Java binary path")); |
| 59 | return; |
| 60 | } |
| 61 | const auto folderToLink = relativePathToBin.chopped(binPath.length()); |
| 62 | |
| 63 | setStatus(tr("Collecting folders to symlink")); |
| 64 | auto entries = QDir(folderToLink).entryInfoList(QDir::NoDotAndDotDot | QDir::AllEntries); |
| 65 | QList<FS::LinkPair> files; |
| 66 | setProgress(0, entries.length()); |
| 67 | for (auto& entry : entries) { |
| 68 | files.append({ entry.absoluteFilePath(), FS::PathCombine(m_path, entry.fileName()) }); |
| 69 | } |
| 70 | |
| 71 | setStatus(tr("Symlinking Java binary path")); |
| 72 | FS::create_link folderLink(files); |
| 73 | connect(&folderLink, &FS::create_link::fileLinked, [this](QString src, QString dst) { setProgress(m_progress + 1, m_progressTotal); }); |
| 74 | if (!folderLink()) { |
| 75 | emitFailed(folderLink.getOSError().message().c_str()); |
| 76 | } else { |
| 77 | emitSucceeded(); |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | } // namespace Java |
nothing calls this directly
no test coverage detected