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