relative static method

Path relative(
  1. Path outer,
  2. Path inner
)

The path of inner relative to outer; inner must be outer or below it.

Throws StateError otherwise.

Implementation

static Path relative(Path outer, Path inner) {
  if (!outer.contains(inner)) {
    throw StateError(
      'INTERNAL ERROR: innerPath ($inner) is not within outerPath ($outer)',
    );
  }
  if (outer.isEmpty) {
    return inner;
  }
  if (outer.length == inner.length) {
    return empty;
  }
  return Path.fromKeys(inner.segments.sublist(outer.length));
}