MCPcopy Create free account
hub / github.com/TheOfficialFloW/VitaShell / downloadFileProcess

Function downloadFileProcess

network_download.c:225–278  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

223}
224
225int 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, &param);
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
270EXIT:
271 if (thid >= 0)
272 sceKernelWaitThreadEnd(thid, NULL, NULL);
273
274 // Unlock power timers
275 powerUnlock();
276
277 return sceKernelExitDeleteThread(0);
278}

Callers 2

qr_scan_threadFunction · 0.85
network_update_threadFunction · 0.85

Calls 10

powerLockFunction · 0.85
getDownloadFileSizeFunction · 0.85
createStartUpdateThreadFunction · 0.85
downloadFileFunction · 0.85
closeWaitDialogFunction · 0.85
setDialogStepFunction · 0.85
errorDialogFunction · 0.85
sceMsgDialogCloseFunction · 0.85
powerUnlockFunction · 0.85

Tested by

no test coverage detected