| 75 | } |
| 76 | |
| 77 | void processZIP(TexturePack& pack) |
| 78 | { |
| 79 | Q_ASSERT(pack.type() == ResourceType::ZIPFILE); |
| 80 | |
| 81 | QuaZip zip(pack.fileinfo().filePath()); |
| 82 | if (!zip.open(QuaZip::mdUnzip)) |
| 83 | return; |
| 84 | |
| 85 | QuaZipFile file(&zip); |
| 86 | |
| 87 | if (zip.setCurrentFile("pack.txt")) { |
| 88 | if (!file.open(QIODevice::ReadOnly)) { |
| 89 | qCritical() << "Failed to open file in zip."; |
| 90 | zip.close(); |
| 91 | return; |
| 92 | } |
| 93 | |
| 94 | auto data = file.readAll(); |
| 95 | |
| 96 | TexturePackUtils::processPackTXT(pack, std::move(data)); |
| 97 | |
| 98 | file.close(); |
| 99 | } |
| 100 | |
| 101 | if (zip.setCurrentFile("pack.png")) { |
| 102 | if (!file.open(QIODevice::ReadOnly)) { |
| 103 | qCritical() << "Failed to open file in zip."; |
| 104 | zip.close(); |
| 105 | return; |
| 106 | } |
| 107 | |
| 108 | auto data = file.readAll(); |
| 109 | |
| 110 | TexturePackUtils::processPackPNG(pack, std::move(data)); |
| 111 | |
| 112 | file.close(); |
| 113 | } |
| 114 | |
| 115 | zip.close(); |
| 116 | } |
| 117 | |
| 118 | void processPackTXT(TexturePack& pack, QByteArray&& raw_data) |
| 119 | { |
no test coverage detected