code: func ValidateOutputPath(path string) error {
  	dir := filepath.Dir(path)
  	if dir != "" && dir != "." {
  		if _, err := os.Stat(dir); os.IsNotExist(err) {
  			return errors.Errorf("invalid output path: directory %q does not exist", dir)
  		}
  	}
  	// check whether `path` points to a regular file
  	// (if the path exists and doesn't point to a directory)
  	if fileInfo, err := os.Stat(path); !os.IsNotExist(err) {
  		if fileInfo.Mode().IsDir() || fileInfo.Mode().IsRegular() {
  			return nil
  		}
  
  		if err := ValidateOutputPathFileMode(fileInfo.Mode()); err != nil {
  			return errors.Wrapf(err, fmt.Sprintf("invalid output path: %q must be a directory or a regular file", path))
  		}
  	}
  	return nil
  }
docs: // ValidateOutputPath validates the output paths of the `export` and `save` commands.