| 663 | } |
| 664 | |
| 665 | int 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, ¶m); |
| 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); |
nothing calls this directly
no test coverage detected