MCPcopy
hub / github.com/hashicorp/go-getter / copyReader

Function copyReader

get_file_copy.go:34–54  ·  view source on GitHub ↗

copyReader copies from an io.Reader into a file, using umask to create the dst file

(dst string, src io.Reader, fmode, umask os.FileMode, fileSizeLimit int64)

Source from the content-addressed store, hash-verified

32
33// copyReader copies from an io.Reader into a file, using umask to create the dst file
34func copyReader(dst string, src io.Reader, fmode, umask os.FileMode, fileSizeLimit int64) error {
35 dstF, err := os.OpenFile(dst, os.O_RDWR|os.O_CREATE|os.O_TRUNC, fmode)
36 if err != nil {
37 return err
38 }
39 defer dstF.Close()
40
41 if fileSizeLimit > 0 {
42 src = io.LimitReader(src, fileSizeLimit)
43 }
44
45 _, err = io.Copy(dstF, src)
46 if err != nil {
47 return err
48 }
49
50 // Explicitly chmod; the process umask is unconditionally applied otherwise.
51 // We'll mask the mode with our own umask, but that may be different than
52 // the process umask
53 return os.Chmod(dst, mode(fmode, umask))
54}
55
56// copyFile copies a file in chunks from src path to dst path, using umask to create the dst file
57func copyFile(ctx context.Context, dst, src string, disableSymlinks bool, fmode, umask os.FileMode) (int64, error) {

Callers 7

DecompressMethod · 0.85
untarFunction · 0.85
DecompressMethod · 0.85
DecompressMethod · 0.85
DecompressMethod · 0.85
CopyReaderMethod · 0.85
DecompressMethod · 0.85

Calls 2

modeFunction · 0.85
CloseMethod · 0.45

Tested by

no test coverage detected