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

Function hash_thread

io_process.c:665–734  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

663}
664
665int hash_thread(SceSize args_size, HashArguments *args) {
666 SceUID thid = -1;
667
668 // Lock power timers
669 powerLock();
670
671 // Set progress to 0%
672 sceMsgDialogProgressBarSetValue(SCE_MSG_DIALOG_PROGRESSBAR_TARGET_BAR_DEFAULT, 0);
673 sceKernelDelayThread(DIALOG_WAIT); // Needed to see the percentage
674
675 uint64_t max = (uint64_t)(getFileSize(args->file_path) / TRANSFER_SIZE);
676
677 // SHA1 process
678 uint64_t value = 0;
679
680 // Spin off a thread to update the progress dialog
681 thid = createStartUpdateThread(max, 0);
682
683 FileProcessParam param;
684 param.value = &value;
685 param.max = max;
686 param.SetProgress = SetProgress;
687 param.cancelHandler = cancelHandler;
688
689 uint8_t sha1out[20];
690 int res = getFileSha1(args->file_path, sha1out, &param);
691 if (res <= 0) {
692 // SHA1 Didn't complete successfully, or was canceled
693 closeWaitDialog();
694 setDialogStep(DIALOG_STEP_CANCELED);
695 errorDialog(res);
696 goto EXIT;
697 }
698
699 // Since we hit here, we're done. Set progress to 100%
700 sceMsgDialogProgressBarSetValue(SCE_MSG_DIALOG_PROGRESSBAR_TARGET_BAR_DEFAULT, 100);
701 sceKernelDelayThread(COUNTUP_WAIT);
702
703 // Close
704 closeWaitDialog();
705
706 char sha1msg[42];
707 memset(sha1msg, 0, sizeof(sha1msg));
708
709 // Construct SHA1 sum string
710 int i;
711 for (i = 0; i < 20; i++) {
712 char string[4];
713 sprintf(string, "%02X", sha1out[i]);
714 strcat(sha1msg, string);
715
716 if (i == 9)
717 strcat(sha1msg, "\n");
718 }
719
720 sha1msg[41] = '\0';
721
722 infoDialog(sha1msg);

Callers

nothing calls this directly

Calls 10

powerLockFunction · 0.85
getFileSizeFunction · 0.85
createStartUpdateThreadFunction · 0.85
getFileSha1Function · 0.85
closeWaitDialogFunction · 0.85
setDialogStepFunction · 0.85
errorDialogFunction · 0.85
infoDialogFunction · 0.85
powerUnlockFunction · 0.85

Tested by

no test coverage detected