From 8b9a113206dcea4d75cf3177058a7eeaa17b8dd0 Mon Sep 17 00:00:00 2001 From: Graeme Geldenhuys Date: Fri, 19 Mar 2010 15:46:49 +0200 Subject: New convenience string functions. * fpgAppendPathDelim() * fpgRemovePathDelim() --- src/corelib/fpg_stringutils.pas | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/corelib') diff --git a/src/corelib/fpg_stringutils.pas b/src/corelib/fpg_stringutils.pas index 2253c149..f97f1b61 100644 --- a/src/corelib/fpg_stringutils.pas +++ b/src/corelib/fpg_stringutils.pas @@ -46,6 +46,8 @@ procedure Delete8(var S: string; Index, Size: integer); procedure Insert8(const Source: string; var S: string; Index: integer); function fpgCharAt(const s: TfpgString; Index: integer): TfpgChar; +function fpgAppendPathDelim(const Path: TfpgString): TfpgString; +function fpgRemovePathDelim(const Path: TfpgString): TfpgString; implementation @@ -317,6 +319,21 @@ begin Result := UTF8Copy(s, Index, 1); end; +function fpgAppendPathDelim(const Path: TfpgString): TfpgString; +begin + if (Path <> '') and (Path[Length(Path)] <> PathDelim) then + Result := Path + PathDelim + else + Result := Path; +end; + +function fpgRemovePathDelim(const Path: TfpgString): TfpgString; +begin + if (Path <> '') and (Path[Length(Path)] = PathDelim) then + Result := LeftStr(Path, Length(Path)-1) + else + Result := Path; +end; end. -- cgit v1.2.3-70-g09d2