MCPcopy Create free account
hub / github.com/ElyPrismLauncher/Launcher / copyFinished

Method copyFinished

launcher/InstanceCopyTask.cpp:140–182  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

138}
139
140void InstanceCopyTask::copyFinished()
141{
142 auto successful = m_copyFuture.result();
143 if (!successful) {
144 emitFailed(tr("Instance folder copy failed."));
145 return;
146 }
147
148 // FIXME: shouldn't this be able to report errors?
149 auto instanceSettings = std::make_unique<INISettingsObject>(FS::PathCombine(m_stagingPath, "instance.cfg"));
150
151 BaseInstance* inst(new NullInstance(m_globalSettings, std::move(instanceSettings), m_stagingPath));
152 inst->setName(name());
153 inst->setIconKey(m_instIcon);
154 if (!m_keepPlaytime) {
155 inst->resetTimePlayed();
156 }
157 if (m_useLinks) {
158 inst->addLinkedInstanceId(m_origInstance->id());
159 auto allowed_symlinks_file = QFileInfo(FS::PathCombine(inst->gameRoot(), "allowed_symlinks.txt"));
160
161 QByteArray allowed_symlinks;
162 if (allowed_symlinks_file.exists()) {
163 allowed_symlinks.append(FS::read(allowed_symlinks_file.filePath()));
164 if (allowed_symlinks.right(1) != "\n")
165 allowed_symlinks.append("\n"); // we want to be on a new line
166 }
167 allowed_symlinks.append(m_origInstance->gameRoot().toUtf8());
168 allowed_symlinks.append("\n");
169 if (allowed_symlinks_file.isSymLink())
170 FS::deletePath(
171 allowed_symlinks_file
172 .filePath()); // we dont want to modify the original. also make sure the resulting file is not itself a link.
173
174 try {
175 FS::write(allowed_symlinks_file.filePath(), allowed_symlinks);
176 } catch (const FS::FileSystemException& e) {
177 qCritical() << "Failed to write symlink :" << e.cause();
178 }
179 }
180
181 emitSucceeded();
182}
183
184void InstanceCopyTask::copyAborted()
185{

Callers

nothing calls this directly

Calls 15

PathCombineFunction · 0.85
QFileInfoClass · 0.85
readFunction · 0.85
deletePathFunction · 0.85
setIconKeyMethod · 0.80
resetTimePlayedMethod · 0.80
addLinkedInstanceIdMethod · 0.80
appendMethod · 0.80
filePathMethod · 0.80
causeMethod · 0.80
writeFunction · 0.70
resultMethod · 0.45

Tested by

no test coverage detected