findParent method
Recursively goes up and tries to find a Directory matching predicate
Returns null
when reaching root (/) without a match
Implementation
Directory? findParent(bool Function(Directory dir) predicate) {
var dir = this;
while (true) {
if (predicate(dir)) {
return dir;
}
final parent = dir.parent;
if (canonicalize(dir.path) == canonicalize(parent.path)) {
// not found
return null;
}
dir = dir.parent;
}
}