round required space up instead of down (thanks Ippi)

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@4252 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
kichik 2005-09-09 12:13:32 +00:00
parent 4647e56e67
commit 8b91e361ca

View file

@ -780,14 +780,20 @@ static BOOL CALLBACK UninstProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
#endif
static void NSISCALL SetSizeText(int dlgItem, int prefix, unsigned kb)
static void NSISCALL SetSizeText(int dlgItem, int prefix, unsigned kb, int roundUp)
{
char scalestr[32], byte[32];
unsigned sh=20;
int scale=LANG_GIGA;
if (kb < 1024*1024) { sh=10; scale=LANG_MEGA; }
if (kb < 1024) { sh=0; scale=LANG_KILO; }
else if (kb < 1024*1024) { sh=10; scale=LANG_MEGA; }
if (roundUp)
// this will not overflow because currently, installers
// can't contain over 2GB of data and this is not used
// for the available size, but only required size
kb += (1 << sh) / 10; // round up number after decimal point
wsprintf(
GetNSISString(g_tmp,prefix)+mystrlen(g_tmp),
@ -959,9 +965,9 @@ static BOOL CALLBACK DirProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
error = NSIS_INSTDIR_NOT_ENOUGH_SPACE;
if (LANG_STR_TAB(LANG_SPACE_REQ)) {
SetSizeText(IDC_SPACEREQUIRED,LANG_SPACE_REQ,total);
SetSizeText(IDC_SPACEREQUIRED,LANG_SPACE_REQ,total,1);
if (available_set)
SetSizeText(IDC_SPACEAVAILABLE,LANG_SPACE_AVAIL,available);
SetSizeText(IDC_SPACEAVAILABLE,LANG_SPACE_AVAIL,available,0);
else
SetUITextNT(IDC_SPACEAVAILABLE,"");
}
@ -1354,7 +1360,7 @@ static BOOL CALLBACK SelProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
RefreshComponents(hwndTree1, hTreeItems);
if (LANG_STR_TAB(LANG_SPACE_REQ)) {
SetSizeText(IDC_SPACEREQUIRED,LANG_SPACE_REQ,sumsecsfield(size_kb));
SetSizeText(IDC_SPACEREQUIRED,LANG_SPACE_REQ,sumsecsfield(size_kb),1);
}
}