[misc] add file system selection to commandline options

* Closes #1236
This commit is contained in:
Charles Stevens 2018-10-23 14:10:52 -05:00 committed by Pete Batard
parent c2c2249207
commit 865678b4b7
2 changed files with 61 additions and 34 deletions

View file

@ -66,7 +66,7 @@ static BOOL user_changed_label = FALSE;
static BOOL app_changed_label = FALSE; static BOOL app_changed_label = FALSE;
static BOOL allowed_filesystem[FS_MAX] = { 0 }; static BOOL allowed_filesystem[FS_MAX] = { 0 };
static int64_t last_iso_blocking_status; static int64_t last_iso_blocking_status;
static int selected_pt = -1, selected_fs = -1; static int selected_pt = -1, selected_fs = FS_UNKNOWN, preselected_fs = FS_UNKNOWN;
static int image_index; static int image_index;
static RECT relaunch_rc = { -65536, -65536, 0, 0}; static RECT relaunch_rc = { -65536, -65536, 0, 0};
static UINT uQFChecked = BST_CHECKED, uMBRChecked = BST_UNCHECKED; static UINT uQFChecked = BST_CHECKED, uMBRChecked = BST_UNCHECKED;
@ -559,13 +559,16 @@ static void SetFSFromISO(void)
fs_mask |= 1<<fs_tmp; fs_mask |= 1<<fs_tmp;
} }
// The presence of a 4GB file forces the use of NTFS as default FS if ((preferred_fs == FS_UNKNOWN) && (preselected_fs != FS_UNKNOWN)) {
if (img_report.has_4GB_file) { // If the FS requested from the command line is valid use it
if (fs_mask & (1 << FS_NTFS)) { if (fs_mask & (1 << preselected_fs)) {
preferred_fs = FS_NTFS; preferred_fs = preselected_fs;
} }
}
if (preferred_fs == FS_UNKNOWN) {
// Syslinux and EFI have precedence over bootmgr (unless the user selected BIOS as target type) // Syslinux and EFI have precedence over bootmgr (unless the user selected BIOS as target type)
} else if ((HAS_SYSLINUX(img_report)) || (HAS_REACTOS(img_report)) || HAS_KOLIBRIOS(img_report) || if ((HAS_SYSLINUX(img_report)) || (HAS_REACTOS(img_report)) || HAS_KOLIBRIOS(img_report) ||
(IS_EFI_BOOTABLE(img_report) && (tt == TT_UEFI) && (!windows_to_go))) { (IS_EFI_BOOTABLE(img_report) && (tt == TT_UEFI) && (!windows_to_go))) {
if (fs_mask & (1 << FS_FAT32)) { if (fs_mask & (1 << FS_FAT32)) {
preferred_fs = FS_FAT32; preferred_fs = FS_FAT32;
@ -577,6 +580,12 @@ static void SetFSFromISO(void)
preferred_fs = FS_NTFS; preferred_fs = FS_NTFS;
} }
} }
}
// The presence of a 4GB file forces the use of NTFS as default FS if available
if (img_report.has_4GB_file && (fs_mask & (1 << FS_NTFS))) {
preferred_fs = FS_NTFS;
}
// Try to select the FS // Try to select the FS
for (i=0; i<ComboBox_GetCount(hFileSystem); i++) { for (i=0; i<ComboBox_GetCount(hFileSystem); i++) {
@ -793,7 +802,7 @@ static BOOL PopulateProperties(void)
GetDrivePartitionData(SelectedDrive.DeviceNumber, fs_type, sizeof(fs_type), FALSE); GetDrivePartitionData(SelectedDrive.DeviceNumber, fs_type, sizeof(fs_type), FALSE);
SetPartitionSchemeAndTargetSystem(FALSE); SetPartitionSchemeAndTargetSystem(FALSE);
// Attempt to reselect the last file system explicitly set by the user // Attempt to reselect the last file system explicitly set by the user
if (!SetFileSystemAndClusterSize((selected_fs == -1) ? fs_type : NULL)) { if (!SetFileSystemAndClusterSize((selected_fs == FS_UNKNOWN) ? fs_type : NULL)) {
SetProposedLabel(-1); SetProposedLabel(-1);
uprintf("No file system is selectable for this drive\n"); uprintf("No file system is selectable for this drive\n");
return FALSE; return FALSE;
@ -2141,7 +2150,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
SetPartitionSchemeAndTargetSystem(FALSE); SetPartitionSchemeAndTargetSystem(FALSE);
// Try to reselect current FS from the drive for non-bootable // Try to reselect current FS from the drive for non-bootable
tmp[0] = 0; tmp[0] = 0;
if ((selected_fs == -1) && (SelectedDrive.DeviceNumber != 0)) if ((selected_fs == FS_UNKNOWN) && (SelectedDrive.DeviceNumber != 0))
GetDrivePartitionData(SelectedDrive.DeviceNumber, tmp, sizeof(tmp), TRUE); GetDrivePartitionData(SelectedDrive.DeviceNumber, tmp, sizeof(tmp), TRUE);
SetFileSystemAndClusterSize(tmp); SetFileSystemAndClusterSize(tmp);
ToggleImageOptions(); ToggleImageOptions();
@ -2670,15 +2679,17 @@ static void PrintUsage(char* appname)
char fname[_MAX_FNAME]; char fname[_MAX_FNAME];
_splitpath(appname, NULL, NULL, fname, NULL); _splitpath(appname, NULL, NULL, fname, NULL);
printf("\nUsage: %s [-f] [-g] [-h] [-i PATH] [-l LOCALE] [-w TIMEOUT]\n", fname); printf("\nUsage: %s [-x] [-g] [-h] [-f FILESYSTEM] [-i PATH] [-l LOCALE] [-w TIMEOUT]\n", fname);
printf(" -f, --fixed\n"); printf(" -x, --extra-devs\n");
printf(" Enable the listing of fixed/HDD USB drives\n"); printf(" List extra devices, such as USB HDDs\n");
printf(" -g, --gui\n"); printf(" -g, --gui\n");
printf(" Start in GUI mode (disable the 'rufus.com' commandline hogger)\n"); printf(" Start in GUI mode (disable the 'rufus.com' commandline hogger)\n");
printf(" -i PATH, --iso=PATH\n"); printf(" -i PATH, --iso=PATH\n");
printf(" Select the ISO image pointed by PATH to be used on startup\n"); printf(" Select the ISO image pointed by PATH to be used on startup\n");
printf(" -l LOCALE, --locale=LOCALE\n"); printf(" -l LOCALE, --locale=LOCALE\n");
printf(" Select the locale to be used on startup\n"); printf(" Select the locale to be used on startup\n");
printf(" -f FILESYSTEM, --filesystem=FILESYSTEM\n");
printf(" Preselect the file system to be preferred when formatting\n");
printf(" -w TIMEOUT, --wait=TIMEOUT\n"); printf(" -w TIMEOUT, --wait=TIMEOUT\n");
printf(" Wait TIMEOUT tens of seconds for the global application mutex to be released.\n"); printf(" Wait TIMEOUT tens of seconds for the global application mutex to be released.\n");
printf(" Used when launching a newer version of " APPLICATION_NAME " from a running application.\n"); printf(" Used when launching a newer version of " APPLICATION_NAME " from a running application.\n");
@ -2760,11 +2771,12 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
HDC hDC; HDC hDC;
MSG msg; MSG msg;
struct option long_options[] = { struct option long_options[] = {
{"fixed", no_argument, NULL, 'f'}, {"extra-devs", no_argument, NULL, 'x'},
{"gui", no_argument, NULL, 'g'}, {"gui", no_argument, NULL, 'g'},
{"help", no_argument, NULL, 'h'}, {"help", no_argument, NULL, 'h'},
{"iso", required_argument, NULL, 'i'}, {"iso", required_argument, NULL, 'i'},
{"locale", required_argument, NULL, 'l'}, {"locale", required_argument, NULL, 'l'},
{"filesystem", required_argument, NULL, 'f'},
{"wait", required_argument, NULL, 'w'}, {"wait", required_argument, NULL, 'w'},
{0, 0, NULL, 0} {0, 0, NULL, 0}
}; };
@ -2836,9 +2848,9 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
// Now enable the hogger before processing the rest of the arguments // Now enable the hogger before processing the rest of the arguments
hogmutex = SetHogger(attached_console, disable_hogger); hogmutex = SetHogger(attached_console, disable_hogger);
while ((opt = getopt_long(argc, argv, "?fghi:w:l:", long_options, &option_index)) != EOF) { while ((opt = getopt_long(argc, argv, "?xghf:i:w:l:", long_options, &option_index)) != EOF) {
switch (opt) { switch (opt) {
case 'f': case 'x':
enable_HDDs = TRUE; enable_HDDs = TRUE;
break; break;
case 'g': case 'g':
@ -2863,6 +2875,21 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
locale_name = safe_strdup(optarg); locale_name = safe_strdup(optarg);
} }
break; break;
case 'f':
if (isdigitU(optarg[0])) {
preselected_fs = (int)strtol(optarg, NULL, 0);
} else {
for (i = 0; i < ARRAYSIZE(FileSystemLabel); i++) {
if (safe_stricmp(optarg, FileSystemLabel[i]) == 0) {
preselected_fs = i;
break;
}
}
}
if ((preselected_fs < FS_UNKNOWN) || (preselected_fs >= FS_MAX))
preselected_fs = FS_UNKNOWN;
selected_fs = preselected_fs;
break;
case 'w': case 'w':
wait_for_mutex = atoi(optarg); wait_for_mutex = atoi(optarg);
break; break;

View file

@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 232, 326 IDD_DIALOG DIALOGEX 12, 12, 232, 326
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_ACCEPTFILES EXSTYLE WS_EX_ACCEPTFILES
CAPTION "Rufus 3.4.1419" CAPTION "Rufus 3.4.1420"
FONT 9, "Segoe UI Symbol", 400, 0, 0x0 FONT 9, "Segoe UI Symbol", 400, 0, 0x0
BEGIN BEGIN
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
@ -392,8 +392,8 @@ END
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 3,4,1419,0 FILEVERSION 3,4,1420,0
PRODUCTVERSION 3,4,1419,0 PRODUCTVERSION 3,4,1420,0
FILEFLAGSMASK 0x3fL FILEFLAGSMASK 0x3fL
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L
@ -411,13 +411,13 @@ BEGIN
VALUE "Comments", "https://akeo.ie" VALUE "Comments", "https://akeo.ie"
VALUE "CompanyName", "Akeo Consulting" VALUE "CompanyName", "Akeo Consulting"
VALUE "FileDescription", "Rufus" VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "3.4.1419" VALUE "FileVersion", "3.4.1420"
VALUE "InternalName", "Rufus" VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011-2018 Pete Batard (GPL v3)" VALUE "LegalCopyright", "© 2011-2018 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "https://www.gnu.org/copyleft/gpl.html" VALUE "LegalTrademarks", "https://www.gnu.org/copyleft/gpl.html"
VALUE "OriginalFilename", "rufus-3.4.exe" VALUE "OriginalFilename", "rufus-3.4.exe"
VALUE "ProductName", "Rufus" VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "3.4.1419" VALUE "ProductVersion", "3.4.1420"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"