Store db_full_size[_u] statistics as UINT64

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6459 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
anders_k 2014-04-05 16:50:11 +00:00
parent 4ac358dc35
commit 45b87a7dc5
4 changed files with 50 additions and 32 deletions

View file

@ -85,17 +85,6 @@ 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
@ -819,6 +808,18 @@ size_t ExpandoStrFmtVaList(wchar_t*Stack, size_t cchStack, wchar_t**ppMalloc, co
return cch;
}
const TCHAR* GetFriendlySize(UINT64 n, unsigned int&fn, GETFRIENDLYSIZEFLAGS f)
{
static const TCHAR* scale[] = {
_T(" bytes"), _T(" KiB"), _T(" MiB"), _T(" GiB"), _T(" TiB")
};
unsigned char s = 0, accurate = f&GFSF_BYTESIFPOSSIBLE;
while(n > ((s || !accurate) ? (1024*1024)-1 : UINT_MAX)) n /= 1024, ++s;
fn = (unsigned int) n;
if (!s) return (f&GFSF_HIDEBYTESCALE) ? _T("") : 1 == fn ? _T(" byte") : scale[s];
return s >= COUNTOF(scale) ? _T(" ?") : scale[s];
}
#if defined(_WIN32) && defined(_UNICODE)
int RunChildProcessRedirected(LPCWSTR cmdprefix, LPCWSTR cmdmain)
{