code: func writeFile(path string, data []byte, mode os.FileMode) error {
  	// Ensure that the parent directory is user-writable, since this is a
  	// requirement in order to make modifications to that directory.
  	parentDir := filepath.Dir(path)
  	if err := filesystem.MakePathUserWritable(parentDir, nil); err != nil {
  		return errors.Annotate(err, "failed to mark parent directory user-writable").
  			InternalReason("path(%q)", parentDir).Err()
  	}
  
  	// Ensure that the target path doesn't already exist. Use filesystem.RemoveAll
  	// in case it exists, but is not user-writable.
  	if err := filesystem.RemoveAll(path); err != nil {
  		return err
  	}
  	if err := ioutil.WriteFile(path, data, mode); err != nil {
  		return errors.Annotate(err, "could not write file contents").InternalReason("path(%q)", path).Err()
  	}
  	return nil
  }
docs: // writeFile writes the contents of data to the specified path. It
  // handles additional cases where the file already exists by deleting it
  // first, allowing it to be overwritten.