MCPcopy Create free account
hub / github.com/FreesmTeam/FreesmLauncher / extractJava

Method extractJava

launcher/java/download/ArchiveDownloadTask.cpp:66–131  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64}
65
66void ArchiveDownloadTask::extractJava(QString input)
67{
68 setStatus(tr("Extracting Java"));
69 if (input.endsWith("tar")) {
70 setStatus(tr("Extracting Java (Progress is not reported for tar archives)"));
71 QFile in(input);
72 if (!in.open(QFile::ReadOnly)) {
73 emitFailed(tr("Unable to open supplied tar file."));
74 return;
75 }
76 if (!Tar::extract(&in, QDir(m_final_path).absolutePath())) {
77 emitFailed(tr("Unable to extract supplied tar file."));
78 return;
79 }
80 emitSucceeded();
81 return;
82 } else if (input.endsWith("tar.gz") || input.endsWith("taz") || input.endsWith("tgz")) {
83 setStatus(tr("Extracting Java (Progress is not reported for tar archives)"));
84 if (!GZTar::extract(input, QDir(m_final_path).absolutePath())) {
85 emitFailed(tr("Unable to extract supplied tar file."));
86 return;
87 }
88 emitSucceeded();
89 return;
90 } else if (input.endsWith("zip")) {
91 auto zip = std::make_shared<QuaZip>(input);
92 if (!zip->open(QuaZip::mdUnzip)) {
93 emitFailed(tr("Unable to open supplied zip file."));
94 return;
95 }
96 auto files = zip->getFileNameList();
97 if (files.isEmpty()) {
98 emitFailed(tr("No files were found in the supplied zip file."));
99 return;
100 }
101 m_task = makeShared<MMCZip::ExtractZipTask>(zip, m_final_path, files[0]);
102
103 auto progressStep = std::make_shared<TaskStepProgress>();
104 connect(m_task.get(), &Task::finished, this, [this, progressStep] {
105 progressStep->state = TaskStepState::Succeeded;
106 stepProgress(*progressStep);
107 });
108
109 connect(m_task.get(), &Task::succeeded, this, &ArchiveDownloadTask::emitSucceeded);
110 connect(m_task.get(), &Task::aborted, this, &ArchiveDownloadTask::emitAborted);
111 connect(m_task.get(), &Task::failed, this, [this, progressStep](QString reason) {
112 progressStep->state = TaskStepState::Failed;
113 stepProgress(*progressStep);
114 emitFailed(reason);
115 });
116 connect(m_task.get(), &Task::stepProgress, this, &ArchiveDownloadTask::propagateStepProgress);
117
118 connect(m_task.get(), &Task::progress, this, [this, progressStep](qint64 current, qint64 total) {
119 progressStep->update(current, total);
120 stepProgress(*progressStep);
121 });
122 connect(m_task.get(), &Task::status, this, [this, progressStep](QString status) {
123 progressStep->status = status;

Callers

nothing calls this directly

Calls 6

openMethod · 0.80
QDirClass · 0.50
isEmptyMethod · 0.45
getMethod · 0.45
updateMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected