code: public DirectoryEntry requireDirectory(Path pathForException)
        throws NoSuchFileException, NotDirectoryException {
      requireExists(pathForException);
      if (!file().isDirectory()) {
        throw new NotDirectoryException(pathForException.toString());
      }
      return this;
    }
docs: Checks that this entry exists and links to a directory, throwing an exception if not.
  
  @return this
  @throws NoSuchFileException if this entry does not exist
  @throws NotDirectoryException if this entry does not link to a directory