[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:
Pete Batard 2012-02-15 00:52:40 +00:00
parent e17de3312f
commit f4ed6e4650
9 changed files with 95 additions and 35 deletions

View file

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