| 241 | } |
| 242 | |
| 243 | const BoxedAppIcon* BoxedApp::getIconTexture(int iconSize) { |
| 244 | if (iconSize==0) { |
| 245 | iconSize = UiSettings::ICON_SIZE; |
| 246 | } |
| 247 | if (!this->iconsBySize.contains(iconSize)) { |
| 248 | int width = 0; |
| 249 | int height = 0; |
| 250 | std::shared_ptr<U8[]> data; |
| 251 | BString nativeExePath = this->container->getNativePathForApp(*this); |
| 252 | |
| 253 | if (Fs::doesNativePathExist(nativeExePath)) { |
| 254 | data = extractIconFromExe(this->container->getNativePathForApp(*this), iconSize, &width, &height); |
| 255 | } else { |
| 256 | BString nativeDir = this->container->getDir().stringByApppendingPath("tmp"); |
| 257 | std::shared_ptr<FileSystemZip> fs = container->getFileSystem().lock(); |
| 258 | if (fs) { |
| 259 | FsZip::extractFileFromZip(fs->filePath, this->path.substr(1) + "/" + this->cmd, nativeDir); |
| 260 | BString nativePath = nativeDir.stringByApppendingPath(this->cmd); |
| 261 | data = extractIconFromExe(nativePath, iconSize, &width, &height); |
| 262 | Fs::deleteNativeFile(nativePath); |
| 263 | } |
| 264 | } |
| 265 | if (!data) { |
| 266 | if (Fs::doesNativePathExist(this->iconPath)) { |
| 267 | data.reset(LoadImageFromFile(this->iconPath.c_str(), &width, &height)); |
| 268 | } |
| 269 | } |
| 270 | if (data) { |
| 271 | this->iconsBySize.set(iconSize, new BoxedAppIcon(data, width, height)); |
| 272 | } else { |
| 273 | this->iconsBySize.set(iconSize, nullptr); |
| 274 | } |
| 275 | } |
| 276 | return this->iconsBySize[iconSize]; |
| 277 | } |
| 278 | |
| 279 | void BoxedApp::remove() { |
| 280 | Fs::deleteNativeFile(this->iniFilePath); |
no test coverage detected