1
0
mirror of synced 2024-12-22 17:23:07 +01:00

Added: AFailIfSame parameter

This commit is contained in:
Mark van Renswoude 2005-02-15 15:02:57 +00:00
parent 288b338f74
commit a2368d1f65

View File

@ -89,10 +89,12 @@ type
*
* @param AChild the path to check
* @param AParent the path which is supposed to be the parent
* @param AFailIfSame if True, fails if the child path is the parent path
* @result True if the child is indeed a child of the parent,
* False otherwise.
*}
function ChildPath(const AChild, AParent: String): Boolean;
function ChildPath(const AChild, AParent: String;
const AFailIfSame: Boolean = False): Boolean;
{** Determines if one path is the child of another path.
*
@ -105,10 +107,12 @@ type
*
* @param AChild the path to check
* @param AParent the path which is supposed to be the parent
* @param AFailIfSame if True, fails if the child path is the parent path
* @result True if the child is indeed a child of the parent,
* False otherwise.
*}
function ChildPathEx(var AChild, AParent: String): Boolean;
function ChildPathEx(var AChild, AParent: String;
const AFailIfSame: Boolean = False): Boolean;
implementation
uses
@ -353,7 +357,8 @@ begin
end;
function ChildPath(const AChild, AParent: String): Boolean;
function ChildPath(const AChild, AParent: String;
const AFailIfSame: Boolean): Boolean;
var
sChild: String;
sParent: String;
@ -361,14 +366,17 @@ var
begin
sChild := AChild;
sParent := AParent;
Result := ChildPathEx(sChild, sParent);
Result := ChildPathEx(sChild, sParent, AFailIfSame);
end;
function ChildPathEx(var AChild, AParent: String): Boolean;
function ChildPathEx(var AChild, AParent: String;
const AFailIfSame: Boolean): Boolean;
begin
AChild := ExcludeTrailingPathDelimiter(ExpandFileName(AChild));
AParent := ExcludeTrailingPathDelimiter(ExpandFileName(AParent));
Result := SameTextS(AChild, AParent);
Result := SameTextS(AChild, AParent) and
((not AFailIfSame) or
(Length(AChild) > Length(AParent));
end;
end.