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

Method copyFinished

launcher/InstanceCopyTask.cpp:142–184  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

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
existsMethod · 0.80
appendMethod · 0.80
filePathMethod · 0.80
causeMethod · 0.80
writeFunction · 0.70

Tested by

no test coverage detected