| 223 | } |
| 224 | |
| 225 | int downloadFileProcess(const char *url, const char *dest, int successStep) { |
| 226 | SceUID thid = -1; |
| 227 | |
| 228 | // Lock power timers |
| 229 | powerLock(); |
| 230 | |
| 231 | // Set progress to 0% |
| 232 | sceMsgDialogProgressBarSetValue(SCE_MSG_DIALOG_PROGRESSBAR_TARGET_BAR_DEFAULT, 0); |
| 233 | sceKernelDelayThread(DIALOG_WAIT); // Needed to see the percentage |
| 234 | |
| 235 | // File size |
| 236 | uint64_t size = 0; |
| 237 | getDownloadFileSize(url, &size); |
| 238 | |
| 239 | // Update thread |
| 240 | thid = createStartUpdateThread(size, 1); |
| 241 | |
| 242 | // Download |
| 243 | uint64_t value = 0; |
| 244 | |
| 245 | FileProcessParam param; |
| 246 | param.value = &value; |
| 247 | param.max = size; |
| 248 | param.SetProgress = SetProgress; |
| 249 | param.cancelHandler = cancelHandler; |
| 250 | |
| 251 | int res = downloadFile(url, dest, ¶m); |
| 252 | if (res <= 0) { |
| 253 | sceIoRemove(dest); |
| 254 | closeWaitDialog(); |
| 255 | setDialogStep(DIALOG_STEP_CANCELED); |
| 256 | errorDialog(res); |
| 257 | goto EXIT; |
| 258 | } |
| 259 | |
| 260 | // Set progress to 100% |
| 261 | sceMsgDialogProgressBarSetValue(SCE_MSG_DIALOG_PROGRESSBAR_TARGET_BAR_DEFAULT, 100); |
| 262 | sceKernelDelayThread(COUNTUP_WAIT); |
| 263 | |
| 264 | // Close |
| 265 | if (successStep != 0) { |
| 266 | sceMsgDialogClose(); |
| 267 | setDialogStep(successStep); |
| 268 | } |
| 269 | |
| 270 | EXIT: |
| 271 | if (thid >= 0) |
| 272 | sceKernelWaitThreadEnd(thid, NULL, NULL); |
| 273 | |
| 274 | // Unlock power timers |
| 275 | powerUnlock(); |
| 276 | |
| 277 | return sceKernelExitDeleteThread(0); |
| 278 | } |
no test coverage detected