1
1
Fork 0
mirror of https://github.com/pbatard/rufus.git synced 2024-08-14 23:57:05 +00:00

[misc] add Ctrl-SELECT option to provide additional content

* For now only .zip archives are supported
This commit is contained in:
Pete Batard 2020-06-10 21:25:33 +01:00
parent 71ede6d9a0
commit e554d2b4e0
No known key found for this signature in database
GPG key ID: 38E0CF5E69EDD671
7 changed files with 63 additions and 16 deletions

View file

@ -9,6 +9,7 @@ o v3.*
- *UPDATED* MSG_068 "Error while partitioning drive." -> "Could not partition drive."
You can test this new message with <Alt>-<G>
- *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 (...)"

View file

@ -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:"

View file

@ -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<nul_pos; i++)
if (psz_fullpath[i] == '/') psz_fullpath[i] = '\\';
for (i = 0; i < nul_pos; i++)
if (psz_fullpath[i] == '/')
psz_fullpath[i] = '\\';
safe_sprintf(&psz_fullpath[nul_pos], 24, " (%s)", SizeToHumanReadable(file_length, TRUE, FALSE));
uprintf("Extracting: %s\n", psz_fullpath);
safe_sprintf(&psz_fullpath[nul_pos], 24, " (%s)", SizeToHumanReadable(file_length, FALSE, FALSE));
PrintStatus(0, MSG_000, psz_fullpath); // MSG_000 is "%s"
// ISO9660 cannot handle backslashes
for (i=0; i<nul_pos; i++)
if (psz_fullpath[i] == '\\') psz_fullpath[i] = '/';
for (i = 0; i < nul_pos; i++)
if (psz_fullpath[i] == '\\')
psz_fullpath[i] = '/';
// Remove the appended size for extraction
psz_fullpath[nul_pos] = 0;
}
static void alt_print_extracted_file(const char* psz_fullpath, uint64_t file_length)
{
uprintf("Extracting: %s (%s)", psz_fullpath, SizeToHumanReadable(file_length, FALSE, FALSE));
PrintStatus(0, MSG_000, psz_fullpath);
}
// Convert from time_t to FILETIME
// Uses 3 static entries so that we can convert 3 concurrent values at the same time
static LPFILETIME __inline to_filetime(time_t t)
@ -1079,6 +1089,12 @@ out:
RunCommand("compact /u bootmgr* efi/boot/*.efi", dest_dir, TRUE);
}
StrArrayDestroy(&modified_path);
if (archive_path != NULL) {
uprintf("● Adding files from %s", archive_path);
bled_init(NULL, NULL, NULL, NULL, alt_print_extracted_file, NULL);
bled_uncompress_to_dir(archive_path, dest_dir, BLED_COMPRESSION_ZIP);
bled_exit();
}
}
if (p_iso != NULL)
iso9660_close(p_iso);

View file

@ -1052,6 +1052,17 @@ static __inline int _accessU(const char* path, int mode)
return ret;
}
static __inline const char* _filenameU(const char* path)
{
int i;
if (path == NULL)
return NULL;
for (i = strlen(path) - 1; 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)
{

View file

@ -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);

View file

@ -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;

View file

@ -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"