Mega Code Archive

 
Categories / Delphi / Strings
 

Ensure that a path name ends with a delimiter

Title: ensure that a path name ends with a delimiter '\' ? { For People (as I am) who can't manage with all of this function names and forget some "jewels". You should sometimes "rename" such procedures if it helps you to remember. } { Die Unit Sysutils verbirgt einige Funktionen, die oft in Vergessenheit geraten. Kapselt die Funktion aus "Sysutils" in einer Funktion mit einem "ansprechenden" Namen. } { IncludeTrailingBackslash } // Adds '\' to the end of a string if it is not already there. // Die Funktion gibt einen Pfadnamen mit dem abschlie enden Zeichen '\' zur ck. function CheckPfadEnd(const P: string): string; begin Result := IncludeTrailingBackslash(P); end; { ExcludeTrailingBackslash } // Removes one '\' from the end of a string if it is there. // Die Funktion gibt einen Pfadnamen ohne das abschlie ende Zeichen \ zur ck. MyDir := ExcludeTrailingBackslash('c:\Windows\'); // --- MyDir = c:\Windows