changeToParentDirectory method

void changeToParentDirectory()

Changes the current working directory to the parent directory.

Implementation

void changeToParentDirectory() {
  if (currentDirectory == rootDirectory) {
    throw FileSystemException("Cannot navigate above root", currentDirectory);
  }

  final parentDir = Directory(currentDirectory).parent;
  if (p.isWithin(rootDirectory, parentDir.path) ||
      parentDir.path == rootDirectory) {
    currentDirectory = parentDir.path;
  } else {
    throw FileSystemException(
        "Access denied: Cannot navigate above root", currentDirectory);
  }
}