Store datablock optimizer statistics as UINT64 in case the same large file is added many times

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6457 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
anders_k 2014-03-31 17:34:58 +00:00
parent ed4f2ab384
commit 4ac358dc35
4 changed files with 32 additions and 12 deletions

View file

@ -85,6 +85,17 @@ unsigned int my_strncpy(TCHAR*Dest, const TCHAR*Src, unsigned int cchMax)
return cch;
}
const TCHAR* GetFriendlySize(UINT64 n, unsigned int&fn, bool accurate)
{
static const TCHAR* names[] = {
_T("bytes"), _T("KiB"), _T("MiB"), _T("GiB"), _T("TiB")
};
unsigned char s = 0;
while(n > ((!accurate || s) ? 1024-1 : UINT_MAX)) n /= 1024, ++s;
fn = (unsigned int) n;
return s >= COUNTOF(names) ? _T("?") : 1 == fn && !s ? _T("byte") : names[s];
}
// Returns 0 if everything is OK
// Returns -1 if can't find the file
// Returns -2 if the file is an invalid bitmap