mirror of
https://github.com/pbatard/rufus.git
synced 2025-05-24 19:54:25 -04:00
[ui] increase projected size to prevent persistence overflow
* If users set the persistent size to max, we may run into a situation where projected size (which is always a rough estimation) is too low. * When persistence is in use, we increase the projected size by 10%, to ensure that the above scenario cannot happen. * Also work around potential issues with Windows APIs when the application is launched from the root of a drive.
This commit is contained in:
parent
9d7e96e293
commit
4f97cdfdc3
5 changed files with 20 additions and 10 deletions
14
src/rufus.c
14
src/rufus.c
|
@ -2342,14 +2342,14 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
|
|||
persistence_size = lPos * MB;
|
||||
for (i = 0; i < persistence_unit_selection; i++)
|
||||
persistence_size *= 1024;
|
||||
if (persistence_size > SelectedDrive.DiskSize - img_report.projected_size)
|
||||
persistence_size = SelectedDrive.DiskSize - img_report.projected_size;
|
||||
if (persistence_size > SelectedDrive.DiskSize - PERCENTAGE(PROJECTED_SIZE_RATIO, img_report.projected_size))
|
||||
persistence_size = SelectedDrive.DiskSize - PERCENTAGE(PROJECTED_SIZE_RATIO, img_report.projected_size);
|
||||
pos = persistence_size / MB;
|
||||
for (i = 0; i < persistence_unit_selection; i++)
|
||||
pos /= 1024;
|
||||
lPos = (LONG)pos;
|
||||
SendMessage(GetDlgItem(hMainDialog, IDC_PERSISTENCE_SLIDER), TBM_SETPOS, TRUE, lPos);
|
||||
if (persistence_size >= (SelectedDrive.DiskSize - img_report.projected_size)) {
|
||||
if (persistence_size >= (SelectedDrive.DiskSize - PERCENTAGE(PROJECTED_SIZE_RATIO, img_report.projected_size))) {
|
||||
static_sprintf(tmp, "%ld", lPos);
|
||||
app_changed_size = TRUE;
|
||||
SetWindowTextU(GetDlgItem(hMainDialog, IDC_PERSISTENCE_SIZE), tmp);
|
||||
|
@ -3185,6 +3185,14 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
|||
uprintf("Could not get current directory: %s", WindowsErrorString());
|
||||
app_dir[0] = 0;
|
||||
}
|
||||
// Microsoft has a bad habit of making some of its APIs (_chdir/_wchdir) break
|
||||
// when app_dir is a drive letter that doesn't have a trailing backslash. For
|
||||
// instance _chdir("F:") does not change the directory, whereas _chdir("F:\\")
|
||||
// does. So make sure we add a trailing backslash if the app_dir is a drive.
|
||||
if ((app_dir[1] == ':') && (app_dir[2] == 0)) {
|
||||
app_dir[2] = '\\';
|
||||
app_dir[3] = 0;
|
||||
}
|
||||
if (GetSystemDirectoryU(system_dir, sizeof(system_dir)) == 0) {
|
||||
uprintf("Could not get system directory: %s", WindowsErrorString());
|
||||
static_strcpy(system_dir, "C:\\Windows\\System32");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue