code: func getCheckpointDir(checkDir, checkpointID, ctrName, ctrID, ctrCheckpointDir string, create bool) (string, error) {
  	var checkpointDir string
  	var err2 error
  	if checkDir != "" {
  		checkpointDir = checkDir
  	} else {
  		checkpointDir = ctrCheckpointDir
  	}
  	checkpointAbsDir := filepath.Join(checkpointDir, checkpointID)
  	stat, err := os.Stat(checkpointAbsDir)
  	if create {
  		switch {
  		case err == nil && stat.IsDir():
  			err2 = fmt.Errorf("checkpoint with name %s already exists for container %s", checkpointID, ctrName)
  		case err != nil && os.IsNotExist(err):
  			err2 = os.MkdirAll(checkpointAbsDir, 0700)
  		case err != nil:
  			err2 = err
  		case err == nil:
  			err2 = fmt.Errorf("%s exists and is not a directory", checkpointAbsDir)
  		}
  	} else {
  		switch {
  		case err != nil:
  			err2 = fmt.Errorf("checkpoint %s does not exist for container %s", checkpointID, ctrName)
  		case err == nil && stat.IsDir():
  			err2 = nil
  		case err == nil:
  			err2 = fmt.Errorf("%s exists and is not a directory", checkpointAbsDir)
  		}
  	}
  	return checkpointAbsDir, err2
  }
docs: // getCheckpointDir verifies checkpoint directory for create,remove, list options and checks if checkpoint already exists