| 294 | } |
| 295 | |
| 296 | bool World::install(const QString& to, const QString& name) |
| 297 | { |
| 298 | auto finalPath = FS::PathCombine(to, FS::DirNameFromString(m_actualName, to)); |
| 299 | if (!FS::ensureFolderPathExists(finalPath)) { |
| 300 | return false; |
| 301 | } |
| 302 | bool ok = false; |
| 303 | if (m_containerFile.isFile()) { |
| 304 | QuaZip zip(m_containerFile.absoluteFilePath()); |
| 305 | if (!zip.open(QuaZip::mdUnzip)) { |
| 306 | return false; |
| 307 | } |
| 308 | ok = !MMCZip::extractSubDir(&zip, m_containerOffsetPath, finalPath); |
| 309 | } else if (m_containerFile.isDir()) { |
| 310 | QString from = m_containerFile.filePath(); |
| 311 | ok = FS::copy(from, finalPath)(); |
| 312 | } |
| 313 | |
| 314 | if (ok && !name.isEmpty() && m_actualName != name) { |
| 315 | QFileInfo finalPathInfo(finalPath); |
| 316 | World newWorld(finalPathInfo); |
| 317 | if (newWorld.isValid()) { |
| 318 | newWorld.rename(name); |
| 319 | } |
| 320 | } |
| 321 | return ok; |
| 322 | } |
| 323 | |
| 324 | bool World::rename(const QString& newName) |
| 325 | { |
no test coverage detected