github.com/jlowellwofford/u-root@v1.0.0/pkg/cp/cp.go (about)

     1  // Copyright 2018 the u-root Authors. All rights reserved
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package cp
     6  
     7  import (
     8  	"io"
     9  	"os"
    10  )
    11  
    12  // Copy src file to dst file.
    13  func Copy(src, dst string) error {
    14  	r, err := os.Open(src)
    15  	if err != nil {
    16  		return err
    17  	}
    18  	defer r.Close()
    19  
    20  	w, err := os.Create(dst)
    21  	if err != nil {
    22  		return err
    23  	}
    24  	defer w.Close()
    25  
    26  	_, err = io.Copy(w, r)
    27  	return err
    28  }