From bb76f1f636d1842c06fa540129267cb5adf218d0 Mon Sep 17 00:00:00 2001 From: Pete Batard Date: Thu, 29 Mar 2012 20:27:53 +0100 Subject: [PATCH] [ui] report ISO progress in main/icon progressbar * Also improve granularity for ISO progress * Also fixes an issue with badblocks report --- src/badblocks.c | 3 +++ src/format.c | 12 ++++++++---- src/iso.c | 4 +++- src/rufus.c | 25 ++++++++++++++++--------- src/rufus.h | 1 + src/rufus.rc | 12 ++++++------ 6 files changed, 37 insertions(+), 20 deletions(-) diff --git a/src/badblocks.c b/src/badblocks.c index 8082a6ed..7be49e4d 100644 --- a/src/badblocks.c +++ b/src/badblocks.c @@ -566,6 +566,9 @@ BOOL BadBlocks(HANDLE hPhysicalDrive, ULONGLONG disk_size, size_t block_size, blk_t first_block = 0, last_block = disk_size/block_size; if (report == NULL) return FALSE; + num_read_errors = 0; + num_write_errors = 0; + num_corruption_errors = 0; report->bb_count = 0; if (fd != NULL) { log_fd = fd; diff --git a/src/format.c b/src/format.c index 9594deb6..27bd25c4 100644 --- a/src/format.c +++ b/src/format.c @@ -659,7 +659,7 @@ static BOOL SetupWinPE(char drive_letter) continue; uprintf(" 0x%08X: '%s' -> '%s'\n", i, &buf[i], patch_str_rep[j]); strcpy(&buf[i], patch_str_rep[j]); - i += max(strlen(patch_str_org[j]), strlen(patch_str_rep[j])); // in case org is a substring of rep + i += (DWORD)max(strlen(patch_str_org[j]), strlen(patch_str_rep[j])); // in case org is a substring of rep } } } @@ -898,8 +898,8 @@ DWORD WINAPI FormatThread(LPVOID param) goto out; if (IsChecked(IDC_DOS)) { - UpdateProgress(OP_DOS, -1.0f); if ((dt == DT_WINME) || (dt == DT_FREEDOS)) { + UpdateProgress(OP_DOS, -1.0f); PrintStatus(0, TRUE, "Copying DOS files..."); if (!ExtractDOS(drive_name)) { if (!FormatStatus) @@ -908,6 +908,7 @@ DWORD WINAPI FormatThread(LPVOID param) } } else if (dt == DT_ISO) { if (iso_path != NULL) { + UpdateProgress(OP_DOS, 0.0f); PrintStatus(0, TRUE, "Copying ISO files..."); drive_name[2] = 0; if (!ExtractISO(iso_path, drive_name, FALSE)) { @@ -922,14 +923,17 @@ DWORD WINAPI FormatThread(LPVOID param) FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|APPERR(ERROR_CANT_PATCH); } } + UpdateProgress(OP_FINALIZE, -1.0f); + PrintStatus(0, TRUE, "Finalizing..."); if (IsChecked(IDC_SET_ICON)) SetAutorun(drive_name); - UpdateProgress(OP_DOS, -1.0f); // Issue another complete remount before we exit, to ensure we're clean RemountVolume(drive_name[0]); // NTFS fixup (WinPE/AIK images don't seem to boot without an extra checkdisk) - if ((dt == DT_ISO) && (fs == FS_NTFS)) + if ((dt == DT_ISO) && (fs == FS_NTFS)) { CheckDisk(drive_name[0]); + UpdateProgress(OP_FINALIZE, -1.0f); + } } out: diff --git a/src/iso.c b/src/iso.c index 66b0db48..ee71da57 100644 --- a/src/iso.c +++ b/src/iso.c @@ -44,7 +44,7 @@ // How often should we update the progress bar (in 2K blocks) as updating // the progress bar for every block will bring extraction to a crawl -#define PROGRESS_THRESHOLD 1024 +#define PROGRESS_THRESHOLD 128 #define FOUR_GIGABYTES 4294967296LL // Needed for UDF ISO access @@ -237,6 +237,7 @@ static int udf_extract_files(udf_t *p_udf, udf_dirent_t *p_udf_dirent, const cha i_file_length -= i_read; if (nb_blocks++ % PROGRESS_THRESHOLD == 0) { SendMessage(hISOProgressBar, PBM_SETPOS, (WPARAM)((MAX_PROGRESS*nb_blocks)/total_blocks), 0); + UpdateProgress(OP_DOS, 100.0f*nb_blocks/total_blocks); } } // If you have a fast USB 3.0 device, the default Windows buffering does an @@ -352,6 +353,7 @@ static int iso_extract_files(iso9660_t* p_iso, const char *psz_path) i_file_length -= ISO_BLOCKSIZE; if (nb_blocks++ % PROGRESS_THRESHOLD == 0) { SendMessage(hISOProgressBar, PBM_SETPOS, (WPARAM)((MAX_PROGRESS*nb_blocks)/total_blocks), 0); + UpdateProgress(OP_DOS, 100.0f*nb_blocks/total_blocks); } } ISO_BLOCKING(safe_closehandle(file_handle)); diff --git a/src/rufus.c b/src/rufus.c index 358a9c31..1f09debf 100644 --- a/src/rufus.c +++ b/src/rufus.c @@ -698,9 +698,11 @@ static BOOL GetUSBDevices(DWORD devnum) */ static void InitProgress(void) { - int i; + int i, dt, fs; float last_end = 0.0f, slots_discrete = 0.0f, slots_analog = 0.0f; + fs = (int)ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem)); + dt = (int)ComboBox_GetItemData(hDOSType, ComboBox_GetCurSel(hDOSType)); memset(&nb_slots, 0, sizeof(nb_slots)); memset(&slot_end, 0, sizeof(slot_end)); previous_end = 0.0f; @@ -711,15 +713,18 @@ static void InitProgress(void) } if (IsChecked(IDC_DOS)) { // 1 extra slot for PBR writing - switch (ComboBox_GetItemData(hDOSType, ComboBox_GetCurSel(hDOSType))) { + switch (dt) { case DT_WINME: - nb_slots[OP_DOS] = 4+1; + nb_slots[OP_DOS] = 3+1; break; case DT_FREEDOS: - nb_slots[OP_DOS] = 6+1; + nb_slots[OP_DOS] = 5+1; + break; + case DT_ISO: + nb_slots[OP_DOS] = -1; break; default: - nb_slots[OP_DOS] = 3+1; + nb_slots[OP_DOS] = 2+1; break; } } @@ -730,6 +735,7 @@ static void InitProgress(void) if (!IsChecked(IDC_QUICKFORMAT)) { nb_slots[OP_FORMAT] = -1; } + nb_slots[OP_FINALIZE] = ((dt == DT_ISO) && (fs == FS_NTFS))?2:1; for (i=0; i 0) { @@ -1430,6 +1436,11 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA return (INT_PTR)TRUE; } FormatStatus = 0; + // Reset all progress bars + SendMessage(hProgress, PBM_SETSTATE, (WPARAM)PBST_NORMAL, 0); + SetTaskbarProgressState(TASKBAR_NORMAL); + SetTaskbarProgressValue(0, MAX_PROGRESS); + SendMessage(hProgress, PBM_SETPOS, 0, 0); selection_default = (int)ComboBox_GetItemData(hDOSType, ComboBox_GetCurSel(hDOSType)); nDeviceIndex = ComboBox_GetCurSel(hDeviceList); if (nDeviceIndex != CB_ERR) { @@ -1462,10 +1473,6 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA _snwprintf(wstr, ARRAYSIZE(wstr), L"WARNING: ALL DATA ON DEVICE %s\r\nWILL BE DESTROYED.\r\n" L"To continue with this operation, click OK. To quit click CANCEL.", wtmp); if (MessageBoxW(hMainDialog, wstr, L"Rufus", MB_OKCANCEL|MB_ICONWARNING) == IDOK) { - // Reset all progress bars - SendMessage(hProgress, PBM_SETSTATE, (WPARAM)PBST_NORMAL, 0); - SetTaskbarProgressState(TASKBAR_NORMAL); - SetTaskbarProgressValue(0, MAX_PROGRESS); // Disable all controls except cancel EnableControls(FALSE); DeviceNum = (DWORD)ComboBox_GetItemData(hDeviceList, nDeviceIndex); diff --git a/src/rufus.h b/src/rufus.h index a3756a0e..56e45041 100644 --- a/src/rufus.h +++ b/src/rufus.h @@ -107,6 +107,7 @@ enum action_type { OP_CREATE_FS, OP_FIX_MBR, OP_DOS, + OP_FINALIZE, OP_MAX }; diff --git a/src/rufus.rc b/src/rufus.rc index ddba868b..461854ec 100644 --- a/src/rufus.rc +++ b/src/rufus.rc @@ -30,7 +30,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL IDD_DIALOG DIALOGEX 12, 12, 206, 289 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_APPWINDOW -CAPTION "Rufus v1.2.0.164" +CAPTION "Rufus v1.2.0.165" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN DEFPUSHBUTTON "Start",IDC_START,94,248,50,14 @@ -71,7 +71,7 @@ BEGIN DEFPUSHBUTTON "OK",IDOK,231,175,50,14,WS_GROUP CONTROL "http://rufus.akeo.ie",IDC_ABOUT_RUFUS_URL, "SysLink",WS_TABSTOP,46,47,114,9 - LTEXT "Version 1.2.0 (Build 164)",IDC_STATIC,46,19,78,8 + LTEXT "Version 1.2.0 (Build 165)",IDC_STATIC,46,19,78,8 PUSHBUTTON "License...",IDC_ABOUT_LICENSE,46,175,50,14,WS_GROUP EDITTEXT IDC_ABOUT_COPYRIGHTS,46,107,235,63,ES_MULTILINE | ES_READONLY | WS_VSCROLL LTEXT "Report bugs or request enhancements at:",IDC_STATIC,46,66,187,8 @@ -216,8 +216,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,2,0,164 - PRODUCTVERSION 1,2,0,164 + FILEVERSION 1,2,0,165 + PRODUCTVERSION 1,2,0,165 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -234,13 +234,13 @@ BEGIN BEGIN VALUE "CompanyName", "akeo.ie" VALUE "FileDescription", "Rufus" - VALUE "FileVersion", "1.2.0.164" + VALUE "FileVersion", "1.2.0.165" VALUE "InternalName", "Rufus" VALUE "LegalCopyright", "© 2011 Pete Batard (GPL v3)" VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html" VALUE "OriginalFilename", "rufus.exe" VALUE "ProductName", "Rufus" - VALUE "ProductVersion", "1.2.0.164" + VALUE "ProductVersion", "1.2.0.165" END END BLOCK "VarFileInfo"