From e554d2b4e0373a8b04b8c4a23d435c13a3894957 Mon Sep 17 00:00:00 2001 From: Pete Batard Date: Wed, 10 Jun 2020 21:25:33 +0100 Subject: [PATCH] [misc] add Ctrl-SELECT option to provide additional content * For now only .zip archives are supported --- res/loc/ChangeLog.txt | 1 + res/loc/rufus.loc | 2 +- src/iso.c | 26 +++++++++++++++++++++----- src/msapi_utf8.h | 11 +++++++++++ src/rufus.c | 28 +++++++++++++++++++++++----- src/rufus.h | 1 + src/rufus.rc | 10 +++++----- 7 files changed, 63 insertions(+), 16 deletions(-) diff --git a/res/loc/ChangeLog.txt b/res/loc/ChangeLog.txt index 853cb4c5..b1445d45 100644 --- a/res/loc/ChangeLog.txt +++ b/res/loc/ChangeLog.txt @@ -9,6 +9,7 @@ o v3.* - *UPDATED* MSG_068 "Error while partitioning drive." -> "Could not partition drive." You can test this new message with - - *NEW* MSG_308 "VHD detection" + - *NEW* MSG_309 "Compressed archive" // TODO: Add a test ISO for this. - *NEW* MSG_310 "The ISO you have selected uses UEFI and is small enough to be written as (...)" diff --git a/res/loc/rufus.loc b/res/loc/rufus.loc index 9d00e9a0..0f1c1543 100644 --- a/res/loc/rufus.loc +++ b/res/loc/rufus.loc @@ -566,7 +566,7 @@ t MSG_305 "Use this option to indicate whether you want to use this device to in t MSG_306 "Fast-zeroing drive: %s" t MSG_307 "This may take a while" t MSG_308 "VHD detection" -t MSG_309 "ISO → ESP" +t MSG_309 "Compressed archive" t MSG_310 "The ISO you have selected uses UEFI and is small enough to be written as an EFI System Partition (ESP). " "Writing to an ESP, instead of writing to a generic data partition occupying the whole disk, can be preferable " "for some types of installations.\n\nPlease select the mode that you want to use to write this image:" diff --git a/src/iso.c b/src/iso.c index c6e1413a..d7246159 100644 --- a/src/iso.c +++ b/src/iso.c @@ -48,6 +48,7 @@ #include "resource.h" #include "msapi_utf8.h" #include "localization.h" +#include "bled/bled.h" // 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 @@ -76,6 +77,7 @@ typedef struct { RUFUS_IMG_REPORT img_report; int64_t iso_blocking_status = -1; extern BOOL preserve_timestamps, enable_ntfs_compression; +extern char* archive_path; BOOL enable_iso = TRUE, enable_joliet = TRUE, enable_rockridge = TRUE, has_ldlinux_c32; #define ISO_BLOCKING(x) do {x; iso_blocking_status++; } while(0) static const char* psz_extract_dir; @@ -387,7 +389,7 @@ static void fix_config(const char* psz_fullpath, const char* psz_path, const cha free(src); } -static void print_extracted_file(char* psz_fullpath, int64_t file_length) +static void print_extracted_file(char* psz_fullpath, uint64_t file_length) { size_t i, nul_pos; @@ -395,19 +397,27 @@ static void print_extracted_file(char* psz_fullpath, int64_t file_length) return; // Replace slashes with backslashes and append the size to the path for UI display nul_pos = strlen(psz_fullpath); - for (i=0; i= 0; i--) + if ((path[i] == '/') || (path[i] == '\\')) + return &path[i + 1]; + return path; +} + // returned UTF-8 string must be freed static __inline char* getenvU(const char* varname) { diff --git a/src/rufus.c b/src/rufus.c index ea5296ca..d651e375 100755 --- a/src/rufus.c +++ b/src/rufus.c @@ -126,7 +126,7 @@ char embedded_sl_version_str[2][12] = { "?.??", "?.??" }; char embedded_sl_version_ext[2][32]; char ClusterSizeLabel[MAX_CLUSTER_SIZES][64]; char msgbox[1024], msgbox_title[32], *ini_file = NULL, *image_path = NULL, *short_image_path; -char image_option_txt[128], *fido_url = NULL; +char *archive_path = NULL, image_option_txt[128], *fido_url = NULL; StrArray DriveId, DriveName, DriveLabel, DriveHub, BlockingProcess, ImageList; // Number of steps for each FS for FCC_STRUCTURE_PROGRESS const int nb_steps[FS_MAX] = { 5, 5, 12, 1, 10, 1, 1, 1, 1 }; @@ -2234,6 +2234,24 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA partition_type = (int)ComboBox_GetItemData(hTargetSystem, ComboBox_GetCurSel(hTargetSystem)); return (INT_PTR)TRUE; case IDC_SELECT: + // Ctrl-SELECT is used to select an additional archive of files to extract + // For now only zip archives are supported. + if (GetKeyState(VK_CONTROL) & 0x8000) { + EXT_DECL(arch_ext, NULL, __VA_GROUP__("*.zip"), __VA_GROUP__(lmprintf(MSG_309))); + if (image_path == NULL) + break; + archive_path = FileDialog(FALSE, NULL, &arch_ext, 0); + if (archive_path != NULL) { + struct __stat64 stat64 = { 0 }; + _stat64U(archive_path, &stat64); + img_report.projected_size -= img_report.archive_size; + img_report.archive_size = stat64.st_size; + img_report.projected_size += img_report.archive_size; + uprintf("Using archive: %s (%s)", _filenameU(archive_path), + SizeToHumanReadable(img_report.archive_size, FALSE, FALSE)); + } + break; + } if (select_index == 1) { EnableControls(FALSE, FALSE); DownloadISO(); @@ -2257,6 +2275,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA } break; } else { + safe_free(archive_path); free(old_image_path); } } @@ -2682,11 +2701,10 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA if (persistence_size == 0) { char* iso_image = lmprintf(MSG_036); char* dd_image = lmprintf(MSG_095); - char* esp_image = lmprintf(MSG_309); // If the ISO is small enough to be written as an ESP and we are using GPT add the ISO → ESP option if ((img_report.projected_size < MAX_ISO_TO_ESP_SIZE * MB) && HAS_REGULAR_EFI(img_report) && (partition_type == PARTITION_STYLE_GPT) && IS_FAT(fs_type)) { - char* choices[3] = { lmprintf(MSG_276, iso_image), lmprintf(MSG_277, esp_image), lmprintf(MSG_277, dd_image) }; + char* choices[3] = { lmprintf(MSG_276, iso_image), lmprintf(MSG_277, "ISO → ESP"), lmprintf(MSG_277, dd_image) }; i = SelectionDialog(lmprintf(MSG_274), lmprintf(MSG_275, iso_image, dd_image, iso_image, dd_image), choices, 3); if (i < 0) // Cancel @@ -2713,8 +2731,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA // The ISO is small enough to be written as an ESP and we are using GPT // so ask the users if they want to write it as an ESP. char* iso_image = lmprintf(MSG_036); - char* esp_image = lmprintf(MSG_309); - char* choices[2] = { lmprintf(MSG_276, iso_image), lmprintf(MSG_277, esp_image) }; + char* choices[2] = { lmprintf(MSG_276, iso_image), lmprintf(MSG_277, "ISO → ESP") }; i = SelectionDialog(lmprintf(MSG_274), lmprintf(MSG_310), choices, 2); if (i < 0) // Cancel goto aborted_start; @@ -3643,6 +3660,7 @@ out: ClrAlertPromptHook(); exit_localization(); safe_free(image_path); + safe_free(archive_path); safe_free(locale_name); safe_free(update.download_url); safe_free(update.release_notes); diff --git a/src/rufus.h b/src/rufus.h index baa08b91..c3ed725d 100644 --- a/src/rufus.h +++ b/src/rufus.h @@ -328,6 +328,7 @@ typedef struct { char wininst_path[MAX_WININST][64]; // path to the Windows install image(s) char efi_img_path[128]; // path to an efi.img file uint64_t image_size; + uint64_t archive_size; uint64_t projected_size; int64_t mismatch_size; uint32_t wininst_version; diff --git a/src/rufus.rc b/src/rufus.rc index 05609b15..2b5618e6 100644 --- a/src/rufus.rc +++ b/src/rufus.rc @@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL IDD_DIALOG DIALOGEX 12, 12, 232, 326 STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_ACCEPTFILES -CAPTION "Rufus 3.11.1671" +CAPTION "Rufus 3.11.1672" FONT 9, "Segoe UI Symbol", 400, 0, 0x0 BEGIN LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP @@ -395,8 +395,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 3,11,1671,0 - PRODUCTVERSION 3,11,1671,0 + FILEVERSION 3,11,1672,0 + PRODUCTVERSION 3,11,1672,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -414,13 +414,13 @@ BEGIN VALUE "Comments", "https://rufus.ie" VALUE "CompanyName", "Akeo Consulting" VALUE "FileDescription", "Rufus" - VALUE "FileVersion", "3.11.1671" + VALUE "FileVersion", "3.11.1672" VALUE "InternalName", "Rufus" VALUE "LegalCopyright", "© 2011-2020 Pete Batard (GPL v3)" VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html" VALUE "OriginalFilename", "rufus-3.11.exe" VALUE "ProductName", "Rufus" - VALUE "ProductVersion", "3.11.1671" + VALUE "ProductVersion", "3.11.1672" END END BLOCK "VarFileInfo"