mirror of
https://github.com/pbatard/rufus.git
synced 2025-06-02 07:39:54 -04:00
[misc] fix broken DOS, fix invalid labels and UI improvements
* DOS creation was broken due to missing unlock + close * added label validation to prevent errors * added ellipsis to status bar * also bumped version to rufus next and fixed f/non-f
This commit is contained in:
parent
e17de3312f
commit
f4ed6e4650
9 changed files with 95 additions and 35 deletions
|
@ -161,6 +161,11 @@ static BOOL FormatDrive(char DriveLetter)
|
|||
}
|
||||
}
|
||||
GetWindowTextW(hLabel, wLabel, ARRAYSIZE(wLabel));
|
||||
// If using FAT/FAT32, truncate the label to 11 characters
|
||||
// TODO: use a wchar_t to_valid_label() here
|
||||
if ((wFSType[0] == 'F') && (wFSType[1] == 'A') && (wFSType[2] == 'T')) {
|
||||
wLabel[11] = 0;
|
||||
}
|
||||
uprintf("Using cluster size: %d bytes\n", ComboBox_GetItemData(hClusterSize, ComboBox_GetCurSel(hClusterSize)));
|
||||
format_percent = 0.0f;
|
||||
task_number = 0;
|
||||
|
@ -533,6 +538,8 @@ DWORD WINAPI FormatThread(LPVOID param)
|
|||
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_WRITE_FAULT;
|
||||
goto out;
|
||||
}
|
||||
// We must close and unlock the volume to write files to it
|
||||
safe_unlockclose(hLogicalVolume);
|
||||
break;
|
||||
case DT_ISO_FAT:
|
||||
PrintStatus(0, TRUE, "Installing Syslinux...");
|
||||
|
@ -546,7 +553,6 @@ DWORD WINAPI FormatThread(LPVOID param)
|
|||
// We issue a complete remount of the filesystem at on account of:
|
||||
// - Ensuring the file explorer properly detects that the volume was updated
|
||||
// - Ensuring that an NTFS system will be reparsed so that it becomes bootable
|
||||
// TODO: on cancellation, this can leave the drive unmounted!
|
||||
if (GetVolumeNameForVolumeMountPointA(drive_name, drive_guid, sizeof(drive_guid))) {
|
||||
if (DeleteVolumeMountPointA(drive_name)) {
|
||||
Sleep(200);
|
||||
|
|
|
@ -109,7 +109,7 @@ static int udf_extract_files(udf_t *p_udf, udf_dirent_t *p_udf_dirent, const cha
|
|||
BOOL r;
|
||||
int i_length;
|
||||
size_t i, nul_pos;
|
||||
char* psz_fullpath;
|
||||
char* psz_fullpath = NULL;
|
||||
const char* psz_basename;
|
||||
udf_dirent_t *p_udf_dirent2;
|
||||
uint8_t buf[UDF_BLOCKSIZE];
|
||||
|
|
|
@ -127,6 +127,18 @@ static __inline LRESULT SendMessageLU(HWND hWnd, UINT Msg, WPARAM wParam, const
|
|||
return ret;
|
||||
}
|
||||
|
||||
static __inline int DrawTextExU(HDC hDC, LPCSTR lpchText, int nCount, LPRECT lpRect, UINT uFormat, LPDRAWTEXTPARAMS lpDTParams)
|
||||
{
|
||||
int ret;
|
||||
DWORD err = ERROR_INVALID_DATA;
|
||||
wconvert(lpchText);
|
||||
ret = DrawTextExW(hDC, wlpchText, nCount, lpRect, uFormat, lpDTParams);
|
||||
err = GetLastError();
|
||||
wfree(lpchText);
|
||||
SetLastError(err);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static __inline BOOL SHGetPathFromIDListU(LPCITEMIDLIST pidl, char* pszPath)
|
||||
{
|
||||
BOOL ret = FALSE;
|
||||
|
|
60
src/rufus.c
60
src/rufus.c
|
@ -59,6 +59,7 @@ int default_fs;
|
|||
HWND hDeviceList, hCapacity, hFileSystem, hClusterSize, hLabel, hDOSType, hNBPasses;
|
||||
HWND hISOProgressDlg = NULL, hISOProgressBar, hISOFileName;
|
||||
BOOL bWithFreeDOS, bWithSyslinux;
|
||||
extern char szStatusMessage[256];
|
||||
|
||||
static HANDLE format_thid = NULL;
|
||||
static HWND hDeviceTooltip = NULL, hFSTooltip = NULL, hProgress = NULL;
|
||||
|
@ -951,6 +952,41 @@ BOOL CALLBACK ISOProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Converts a name + ext UTF-8 pair to a valid MS filename.
|
||||
* Returned string is allocated and needs to be freed manually
|
||||
*/
|
||||
void to_valid_label(char* name)
|
||||
{
|
||||
size_t i, j, k;
|
||||
BOOL found;
|
||||
char unauthorized[] = "*?.,;:/\\|+=<>[]";
|
||||
char to_underscore[] = "\t";
|
||||
|
||||
if (name == NULL)
|
||||
return;
|
||||
|
||||
for (i=0, k=0; i<strlen(name); i++) {
|
||||
found = FALSE;
|
||||
for (j=0; j<strlen(unauthorized); j++) {
|
||||
if (name[i] == unauthorized[j]) {
|
||||
found = TRUE; break;
|
||||
}
|
||||
}
|
||||
if (found) continue;
|
||||
found = FALSE;
|
||||
for (j=0; j<strlen(to_underscore); j++) {
|
||||
if (name[i] == to_underscore[j]) {
|
||||
name[k++] = '_';
|
||||
found = TRUE; break;
|
||||
}
|
||||
}
|
||||
if (found) continue;
|
||||
name[k++] = name[i];
|
||||
}
|
||||
name[k] = 0;
|
||||
}
|
||||
|
||||
// The scanning process can be blocking for message processing => use a thread
|
||||
DWORD WINAPI ISOScanThread(LPVOID param)
|
||||
{
|
||||
|
@ -973,10 +1009,11 @@ DWORD WINAPI ISOScanThread(LPVOID param)
|
|||
safe_free(iso_path);
|
||||
} else {
|
||||
for (i=(int)safe_strlen(iso_path); (i>0)&&(iso_path[i]!='\\'); i--);
|
||||
PrintStatus(0, TRUE, "Using ISO: '%s'\n", &iso_path[i+1]);
|
||||
PrintStatus(0, TRUE, "Using ISO: %s\n", &iso_path[i+1]);
|
||||
// Some Linux distros, such as Arch Linux, require the USB drive to have
|
||||
// a specific label => copy the one we got from the ISO image
|
||||
if (iso_report.label[0] != 0) {
|
||||
to_valid_label(iso_report.label);
|
||||
SetWindowTextU(hLabel, iso_report.label);
|
||||
}
|
||||
}
|
||||
|
@ -1122,16 +1159,23 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
|
|||
GetUSBDevices();
|
||||
return (INT_PTR)TRUE;
|
||||
|
||||
// Change the colour of the version text in the status bar
|
||||
// The things one must do to get an ellipsis on the status bar...
|
||||
case WM_DRAWITEM:
|
||||
if (wParam == IDC_STATUS) {
|
||||
pDI = (DRAWITEMSTRUCT*)lParam;
|
||||
SetBkMode(pDI->hDC, TRANSPARENT);
|
||||
SetTextColor(pDI->hDC, GetSysColor(COLOR_3DSHADOW));
|
||||
pDI->rcItem.top += (int)(2.0f * fScale);
|
||||
pDI->rcItem.left += (int)(4.0f * fScale);
|
||||
DrawTextExA(pDI->hDC, szTimer, -1, &pDI->rcItem, DT_LEFT, NULL);
|
||||
return (INT_PTR)TRUE;
|
||||
SetBkMode(pDI->hDC, TRANSPARENT);
|
||||
switch(pDI->itemID) {
|
||||
case 0: // left part
|
||||
DrawTextExU(pDI->hDC, szStatusMessage, -1, &pDI->rcItem,
|
||||
DT_LEFT|DT_END_ELLIPSIS, NULL);
|
||||
return (INT_PTR)TRUE;
|
||||
case 1: // right part
|
||||
SetTextColor(pDI->hDC, GetSysColor(COLOR_3DSHADOW));
|
||||
DrawTextExA(pDI->hDC, szTimer, -1, &pDI->rcItem, DT_LEFT, NULL);
|
||||
return (INT_PTR)TRUE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -1246,9 +1290,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
|
|||
break;
|
||||
}
|
||||
ShowWindow(hSelectISO, SW_SHOW);
|
||||
// Fall through if no ISO is selected
|
||||
if ((iso_path != NULL) || (LOWORD(wParam) == IDC_FILESYSTEM))
|
||||
break;
|
||||
break;
|
||||
case IDC_SELECT_ISO:
|
||||
DestroyTooltip(hISOToolTip);
|
||||
safe_free(iso_path);
|
||||
|
|
12
src/rufus.rc
12
src/rufus.rc
|
@ -33,7 +33,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL
|
|||
IDD_DIALOG DIALOGEX 12, 12, 206, 278
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
EXSTYLE WS_EX_APPWINDOW
|
||||
CAPTION "Rufus v1.1.0.133"
|
||||
CAPTION "Rufus v1.1.1.134"
|
||||
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "Start",IDC_START,94,236,50,14
|
||||
|
@ -71,7 +71,7 @@ BEGIN
|
|||
DEFPUSHBUTTON "OK",IDOK,231,175,50,14,WS_GROUP
|
||||
CONTROL "<a href=""http://rufus.akeo.ie"">http://rufus.akeo.ie</a>",IDC_ABOUT_RUFUS_URL,
|
||||
"SysLink",WS_TABSTOP,46,47,114,9
|
||||
LTEXT "Version 1.1.0 (Build 133)",IDC_STATIC,46,19,78,8
|
||||
LTEXT "Version 1.1.1 (Build 134)",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
|
||||
|
@ -222,8 +222,8 @@ END
|
|||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,1,0,133
|
||||
PRODUCTVERSION 1,1,0,133
|
||||
FILEVERSION 1,1,1,134
|
||||
PRODUCTVERSION 1,1,1,134
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
|
@ -240,13 +240,13 @@ BEGIN
|
|||
BEGIN
|
||||
VALUE "CompanyName", "akeo.ie"
|
||||
VALUE "FileDescription", "Rufus"
|
||||
VALUE "FileVersion", "1.1.0.133"
|
||||
VALUE "FileVersion", "1.1.1.134"
|
||||
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.1.0.133"
|
||||
VALUE "ProductVersion", "1.1.1.134"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
|
|
|
@ -128,12 +128,13 @@ static char err_string[256];
|
|||
* message
|
||||
*/
|
||||
static BOOL bStatusTimerArmed = FALSE;
|
||||
static char szStatusMessage[256] = { 0 };
|
||||
char szStatusMessage[256] = { 0 };
|
||||
static void CALLBACK PrintStatusTimeout(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
|
||||
{
|
||||
bStatusTimerArmed = FALSE;
|
||||
// potentially display lower priority message that was overridden
|
||||
SetDlgItemTextU(hMainDialog, IDC_STATUS, szStatusMessage);
|
||||
SendMessageLU(GetDlgItem(hMainDialog, IDC_STATUS), SB_SETTEXTW,
|
||||
SBT_OWNERDRAW | 0, szStatusMessage);
|
||||
KillTimer(hMainDialog, TID_MESSAGE);
|
||||
}
|
||||
|
||||
|
@ -158,7 +159,8 @@ void PrintStatus(unsigned int duration, BOOL debug, const char *format, ...)
|
|||
uprintf("%s\n", szStatusMessage);
|
||||
|
||||
if ((duration) || (!bStatusTimerArmed)) {
|
||||
SetDlgItemTextU(hMainDialog, IDC_STATUS, szStatusMessage);
|
||||
SendMessageLU(GetDlgItem(hMainDialog, IDC_STATUS), SB_SETTEXTA,
|
||||
SBT_OWNERDRAW | 0, szStatusMessage);
|
||||
}
|
||||
|
||||
if (duration) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue