code: func withPreparedTarget(filesystem fs.Filesystem, from, to string, f func() error) error {
  	// Make sure the destination directory is writeable
  	toDir := filepath.Dir(to)
  	if info, err := filesystem.Stat(toDir); err == nil && info.IsDir() && info.Mode()&0200 == 0 {
  		filesystem.Chmod(toDir, 0755)
  		defer filesystem.Chmod(toDir, info.Mode())
  	}
  
  	// On Windows, make sure the destination file is writeable (or we can't delete it)
  	if runtime.GOOS == "windows" {
  		filesystem.Chmod(to, 0666)
  		if !strings.EqualFold(from, to) {
  			err := filesystem.Remove(to)
  			if err != nil && !fs.IsNotExist(err) {
  				return err
  			}
  		}
  	}
  	return f()
  }
docs: // Tries hard to succeed on various systems by temporarily tweaking directory
  // permissions and removing the destination file when necessary.