Skip to content

Commit

Permalink
TrimEx function
Browse files Browse the repository at this point in the history
  • Loading branch information
pozitronik committed Sep 11, 2018
1 parent a9e8143 commit 38fcab7
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions MRC_Helper.pas
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ function RetryAttemptsToString(Attempt: integer): WideString;
procedure ProcessMessages;
function IncludeSlash(const Str: WideString): WideString;
function NormalizeSlashes(const Str: WideString): WideString;
function TrimEx(const Str: WideString; TrimChar: WideChar): WideString;
function FormatSize(size: Int64; SizeType: integer = TYPE_AUTO): WideString; //Форматируем размер в удобочитаемый вид
//Procedure FileLog(S: WideString);

Expand Down Expand Up @@ -682,6 +683,19 @@ function NormalizeSlashes(const Str: WideString): WideString;
Result := StringReplace(Str, '\', '/', [rfReplaceAll]);
end;

function TrimEx(const Str: WideString; TrimChar: WideChar): WideString;
var
S, E: integer;
begin
S := 1;
while (S <= Length(Str)) and (Str[S] = TrimChar) do
Inc(S);
E := Length(Str);
while (E >= 1) and (Str[E] = TrimChar) do
Dec(E);
SetString(Result, PChar(@Str[S]), E - S + 1);
end;

function FormatSize(size: Int64; SizeType: integer = TYPE_AUTO): WideString; //Форматируем размер в удобочитаемый вид
const
postfixes: array [0 .. 6] of string = ('b', 'kb', 'Mb', 'Gb', 'Tb', 'Pb', 'Eb');
Expand Down

0 comments on commit 38fcab7

Please sign in to comment.