mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
IsChildOf function for AbsolutePath
Iterates up the parent directories to find if this path is a child of the given path.
This commit is contained in:
parent
8231d5252c
commit
8e39f9f4eb
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
@ -209,6 +209,21 @@ namespace Wabbajack.Common
|
||||
return new RelativePath(relPath);
|
||||
}
|
||||
|
||||
public bool IsChildOf(AbsolutePath? parent)
|
||||
{
|
||||
if (parent is null) return false;
|
||||
var child = this;
|
||||
if (child == parent) return true;
|
||||
while (child.Parent.Exists)
|
||||
{
|
||||
if (child.Parent == parent)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
child = child.Parent;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public async Task<string> ReadAllTextAsync()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user