parent method

Option<WindowsPath> parent()

Implementation

Option<WindowsPath> parent() {
  final comps = components().toList();
  if (comps.length == 1) {
    switch (comps.first) {
      case RootDir():
      case Prefix():
        return None;
      case ParentDir():
      case CurDir():
      case Normal():
        return Some(WindowsPath(""));
    }
  }
  if (comps.length > 1) {
    comps.removeLast();
  } else {
    return None;
  }
  if (comps.length == 1) {
    final prefix = comps[0];
    if (prefix case Prefix()) {
      return None;
    }
  }
  return Some(_joinWindowsComponents(comps));
}