isWithin method

bool isWithin(
  1. String otherPath, {
  2. required bool isDir,
})

Implementation

bool isWithin(String otherPath, {required bool isDir}) {
  final otherPathPosix = p.posix.canonicalize(otherPath);
  final isWithin = recurse
      ? path == otherPathPosix || p.isWithin(path, otherPathPosix)
      : path == (isDir ? path == otherPathPosix : p.dirname(otherPathPosix));
  return isWithin && includes(otherPathPosix, isDir: isDir);
}