RxFPC:new function - RxPrettySizeName

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7022 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
alexs75
2019-07-03 08:34:10 +00:00
parent 2fd5a598d4
commit 5c9b5a4f9f
6 changed files with 107 additions and 2 deletions

View File

@ -233,16 +233,18 @@ function RomanToInt(const S: string): Longint; deprecated; //use this function f
procedure StrToStrings(const S:string; const List:TStrings; const Delims:Char);
function FileToString(const AFileName:string):string;
function RxPrettySizeName(ASize:Int64):string;
const
DigitChars = ['0'..'9'];
Brackets = ['(',')','[',']','{','}'];
StdWordDelims = [#0..' ',',','.',';','/','\',':','''','"','`'] + Brackets;
implementation
uses
{$IFDEF WINDOWS}
uses Windows;
Windows,
{$ENDIF}
rxconst;
function StrToOem(const AnsiStr: string): string;
begin
@ -1149,4 +1151,21 @@ begin
Result:='';
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
else
if ASize div (1024 * 1024 * 1024) > 0 then
Result := IntToStr(ASize div (1024 * 1024 * 1024)) + ' ' +sRxGigaByte
else
if ASize div (1024 * 1024) > 0 then
Result := IntToStr(ASize div (1024 * 1024)) + ' ' +sRxMegaByte
else
if ASize div 1024 > 0 then
Result := IntToStr(ASize div (1024)) + ' ' +sRxKiloByte
else
Result := IntToStr(ASize div (1024)) + ' ' +sRxByte;
end;
end.