From d0d3332d5b27dc6f99bb34dcad7e4b8c60f4a4d2 Mon Sep 17 00:00:00 2001 From: alexs75 Date: Thu, 4 Jul 2019 06:29:19 +0000 Subject: [PATCH] RxFPC:RxPrettySizeName - round git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7023 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/rx/trunk/rxtools/rxstrutils.pas | 30 ++++++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/components/rx/trunk/rxtools/rxstrutils.pas b/components/rx/trunk/rxtools/rxstrutils.pas index a18aba551..ef66e45e8 100644 --- a/components/rx/trunk/rxtools/rxstrutils.pas +++ b/components/rx/trunk/rxtools/rxstrutils.pas @@ -1154,18 +1154,38 @@ end; function RxPrettySizeName(ASize: Int64): string; begin if ASize div (1024 * 1024 * 1024 * 1024) > 0 then - Result := IntToStr(ASize div (1024 * 1024 * 1024 * 1024)) + ' ' +sRxTerraByte + begin + if ASize mod (1024 * 1024 * 1024 * 1024) <> 0 then + Result := IntToStr(1 + ASize div (1024 * 1024 * 1024 * 1024)) + ' ' +sRxTerraByte + else + Result := IntToStr(ASize div (1024 * 1024 * 1024 * 1024)) + ' ' +sRxTerraByte + end else if ASize div (1024 * 1024 * 1024) > 0 then - Result := IntToStr(ASize div (1024 * 1024 * 1024)) + ' ' +sRxGigaByte + begin + if ASize mod (1024 * 1024 * 1024) > 0 then + Result := IntToStr(1 + ASize div (1024 * 1024 * 1024)) + ' ' +sRxGigaByte + else + Result := IntToStr(ASize div (1024 * 1024 * 1024)) + ' ' +sRxGigaByte + end else if ASize div (1024 * 1024) > 0 then - Result := IntToStr(ASize div (1024 * 1024)) + ' ' +sRxMegaByte + begin + if ASize mod (1024 * 1024) > 0 then + Result := IntToStr(1 + ASize div (1024 * 1024)) + ' ' +sRxMegaByte + else + Result := IntToStr(ASize div (1024 * 1024)) + ' ' +sRxMegaByte + end else if ASize div 1024 > 0 then - Result := IntToStr(ASize div (1024)) + ' ' +sRxKiloByte + begin + if ASize mod 1024 > 0 then + Result := IntToStr(1 + ASize div (1024)) + ' ' +sRxKiloByte + else + Result := IntToStr(ASize div (1024)) + ' ' +sRxKiloByte + end else - Result := IntToStr(ASize div (1024)) + ' ' +sRxByte; + Result := IntToStr(ASize) + ' ' +sRxByte; end; end.